Re: DB_DataObject::insert() not returning ID
| From: | Justin Patrin | Date: | Thu, 02 Dec 2004 00:12:40 +0000 |
| Subject: | Re: DB_DataObject::insert() not returning ID | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15956@lists.php.net to get a copy of this message | ||
On Tue, 30 Nov 2004 10:19:58 -0800, Ken Restivo <ken@restivo.org> wrote:
> -----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.
>
What's your CREATE TABLE look like?
--
Justin Patrin