Hey Dasprid,
$id = $db->insert('my_table', $data);
is incorrect.
I need to use e.g.:
$db->insert('my_table', $data);
return $db->lastInsertId();
only the insert method of the Zend_Db_Table class will return the id, the
one of the Zend_Db_Adapter will return the number of rows affected.
Thanks all.
(By the way, how is it possible to have more than 1 row affected when you
use ->insert(...) ?)
DASPRiD wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> $id = $db->insert('my_table', $data);
> ...................................
> : ___ _ ___ ___ ___ _ ___ :
> : | \ /_\ / __| _ \ _ (_) \ :
> : | |) / _ \\__ \ _/ / | |) | :
> : |___/_/:\_\___/_| |_|_\_|___/ :
> :........:........................:
> : Web : http://www.dasprids.de :
> : E-mail : [email protected] :
> : Jabber : [email protected] :
> : ICQ : 105677955 :
> :........:........................:
>
>
> debussy007 schrieb:
>> Hello,
>>
>> When I insert a record in a table like $db->insert('my_table', $data); I
>> would like to get the new id generated.
>> ($db is the Db Adapter)
>>
>> What is the best way to achieve this ?
>>
>> When I was using Zend_Db_Table_Abstract I just had to do return
>> $myTable->insert ... and the insert method would return the new id.
>>
>> However the insert method of the Zend_Db_Adapter_Abstract won't return
>> the
>> new id but the number of rows affected (which will always be 1 I guess
>> ...)
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkpiNCsACgkQ0HfT5Ws789DdbACgjJUBZRdafwHoq5XIreIyR7H5
> q3wAoKEg7RF0tiIuBP04VMRwZ6bqglN/
> =rcYA
> -----END PGP SIGNATURE-----
>
>
--
View this message in context:
http://www.nabble.com/Getting-the-id-generated-after-insert-tp24549260p24552365.html
Sent from the Zend Framework mailing list archive at Nabble.com.