Re: DB_DataObject::insert() not returning ID
| From: | Ken Restivo | Date: | Tue, 30 Nov 2004 18:19:58 +0000 |
| Subject: | Re: DB_DataObject::insert() not returning ID | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15921@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tue, Nov 30, 2004 at 02:33:53PM +0800, Alan Knowles wrote:
> >>>On Sun, Nov 14, 2004 at 07:36:41PM -0800, Ken Restivo wrote:
> >>>
> >>>>One more: inserts succeed but always return 1 as an ID.
> >>>>
> >>>>I supposed I can hack around this with a raw query for
> >>>>last_insert_id(), but the docs say insert() should return this.
> >>>>
> >>>
>
> $do->insert() should always return last_insert_id(), unless the schema
> data is wrong (eg. not uptodate or something)
>
> Otherwise you have found a bug..
Well then, I think I have found a bug. The schema is correct AFAICT, there is one primary key and it
is an auto_increment not-null field. The ID does get correctly returned by manually getting
last_insert_id() via raw SQL as my utility hack does. However, DBDO's insert() always returns
1.
I'm using:
DB_DataObject 1.7.2 stable
On PHP 4.3.8 on Debian Woody.
- -ken
- --
- ---------------
The world's most affordable web hosting.
http://www.nearlyfreespeech.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
iD8DBQFBrLnOe8HF+6xeOIcRAuSMAKCFwGStPmlIClDzonZJrzEJ2x2xrACgtT9e
wvVnSaZiX9g9d1hSK45OgVY=
=xLPK
-----END PGP SIGNATURE-----