Re: equivalent to mysql_insert_id()

From: Date: Thu, 01 Jul 2004 04:55:22 +0000
Subject: Re: equivalent to mysql_insert_id()
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-13445@lists.php.net to get a copy of this message
From: "Vern T Takebayashi" <vern@hcc.hawaii.edu> > Please excuse my ignorance as I just started looking at PEAR DB this past > weekend. I have some PHP scripts that use the mysql_insert_id() function > to return the last ID generated using auto_increment. In PEAR, is using > the nextID() function and subtracting one, roughly equivalent to using the > mysql_insert_id() function? I needed this functionality for one old PHP script I converted til use PEAR. My solution was to run this statement after you have used $db->query(). $insertid = $db->getOne('SELECT LAST_INSERT_ID()'); I know that this will only work with MySQL, but it gets the job done. Espen Carlsen

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