2009年2月20日星期五

Re: [fw-db] Insert using Zend DB and an adapter

Hmmm, this gets interesting. I was able to get my insert to work by
assigning an auto-incrementing key. After your response about it should be
able to work, I removed the auto-incrementing key field so I could get the
error message I originally reported. Wouldn't you know it? It worked fine.
So, as you said, this should (and does) work just fine.

Thanks!


Brenton Alker-3 wrote:
>
> prickett wrote:
>> I'm trying to insert a record into a MySql table that has no key. I'm
>> using
>> an adapter and the following code:
>>
>> Zend_Registry::get( "dbAdapter" )->insert( "USERS" , array( "username" =>
>> $this->username , "password" => $this->password ) );
>>
>>
>> This, however, results in a key violation.
>>
>> I see that when you do an insert from a table object (instead of from an
>> adapter) you have the ability to say there is no key:
>>
>> class BugStatus extends Zend_Db_Table_Abstract{
>> protected $_sequence = false;
>> }
>>
>> Is there a way to do this via the adapter too?
>>
>> TIA
>
> What you're doing looks fine. You don't need a key for an insert (in the
> same way you would for and update).
>
> What is the actual "key violation". Are you sure it's not a duplicate
> key because you have username/password (or some other fields) set as
> unique/primary in the database?
>
> --
>
> Brenton Alker
>
> http://blog.tekerson.com/
>
>
>
>

--
View this message in context: http://www.nabble.com/Insert-using-Zend-DB-and-an-adapter-tp22086840p22120445.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: