Re: mysql_insert_id ()
| From: | Stig S. Bakken | Date: | Mon, 25 Feb 2002 08:11:19 +0000 |
| Subject: | Re: mysql_insert_id () | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-898@lists.php.net to get a copy of this message | ||
On Mon, 2002-02-25 at 06:07, David Dahl wrote:
> how do you do "mysql_insert_id ()" with DB::?
You don't. Since DB is trying to be portable, and both auto_increment
and a function to get the last auto-incremented field are
MySQL-specific, that's not how PEAR DB implement this.
You need to use sequences, like this:
$id = $dbh->nextId("sequencename");
$foo = $dbh->query("INSERT INTO table VALUES($id, 1, 2, 3)");
(the first column would be the auto_increment field)
- Stig