Re: lastInsertId -- DB
| From: | Jonas Koch Bentzen | Date: | Thu, 20 Jun 2002 18:24:56 +0000 |
| Subject: | Re: lastInsertId -- DB | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-7245@lists.php.net to get a copy of this message | ||
Mick Van Der Most Van Spijk wrote:
For insert purposes i have build in the mysql.php of DB the very simple function lastInsertId(). This is done for the following reason: after an update i needed the id of the row that was inserted.? Do you mean UPDATE or SELECT? If you use UPDATE, you'll probably have to know the ID beforehand. And if you use INSERT, why not just use nextId()? $nextId = $db->nextId("table_id"); $db->query("INSERT INTO table ( id, name ) VALUES ( $nextId, 'John' )");