Re: Id from insert query

From: Date: Thu, 16 May 2002 10:19:48 +0000
Subject: Re: Id from insert query
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1388@lists.php.net to get a copy of this message
Sam Liddicott wrote: > > > -----Original Message----- > > From: Trond Arve Nordheim [mailto:trond@nordheim.no] > > Sent: 15 May 2002 20:18 > > To: Iwan Birrer > > Cc: pear-general@lists.php.net > > Subject: Re: [PEAR] Id from insert query > > > > > > On Wed, May 15, 2002 at 09:08:11PM +0200, Iwan Birrer wrote: > > > Hello, > > > How do I get the id from a insert query with PEAR DB? With > > mysql it was > > > mysql_insert_id(). > > > > You obtain the ID before inserting using the nextID() function (e.g. > > $dbh->nextID("sequence_name")). See > > http://pear.php.net/manual/en/core.db.nextid.php for more > > information. > > Does this work accross all backend dbs? Most of them: ibase, oci8, mysql, pgsql, fbsql and mssql > What about race conditions etc when > two pages try to insert? > When the backend does not support sequences natively the emulation takes care of race conditions with locks (see for example the mysql implementation). Tomas V.V.Cox

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