Re: DB_DataObject::insert() not returning ID

From: Date: Sat, 04 Dec 2004 21:42:42 +0000
Subject: Re: DB_DataObject::insert() not returning ID
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16012@lists.php.net to get a copy of this message
I am having a similar problem (on postgres) and DBDO 1.7.2. When I set the sequence in the DATABASE.ini file i.e., sequence_TABLE = TABLE_ID_seq it seems to always return TRUE upon (successful) insert. When I set the sequence with the sequenceKey() function, i.e., $TABLE->sequenceKey('ID', TRUE, 'TABLE_ID_seq'); it always returns the last inserted id. I built my classes and schema with createTables and only hand edited the .ini file to have the sequences. matt ------------------------------------------------------------------------
Subject: Re: [PEAR] DB_DataObject::insert() not returning ID From: Justin Patrin <papercrane@gmail.com> Date: Wed, 1 Dec 2004 16:12:40 -0800 To: Ken Restivo <ken@restivo.org> To: Ken Restivo <ken@restivo.org> CC: Alan Knowles <alan@akbkhome.com>, pear-general@lists.php.net Message-ID: <432beae04120116125cf5b3c2@mail.gmail.com> Reply-To: papercrane@reversefold.com MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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?


« previous php.pear.general (#16012) next »