RE: [PEAR] the Pear::DB way to do mysql_insert_id?
| From: | Lukas Smith | Date: | Mon, 02 Dec 2002 17:39:45 +0000 |
| Subject: | RE: [PEAR] the Pear::DB way to do mysql_insert_id? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-2890@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Jeff Bearer [mailto:jbearer@pittsburghlive.com]
> Sent: Monday, December 02, 2002 4:06 PM
> To: PEAR List
> Subject: [PEAR] the Pear::DB way to do mysql_insert_id?
>
> What is the proper PEAR way to get the value that mysql_insert_id()
> gives you when using an auto_increment index.
>
> I'm assuming that the function isn't implemented that way because
other
> databases don't do sequences the same way. I looked through the
> nextId() function and it uses another table to keep the sequence.
>
> Could somebody explain the way this should be implemented with mysql?
This question has been asked several times before .. so you should find
your answer by searching the archives.
But I will explain briefly:
You are very correct that mysql's way of generating unique id's is very
mysql specific. Since PEAR::DB aims to hide such differences between
DB's this method (using a separate table) was introduced to emulate the
behaviour of other RDBMS for generating unique ID's (that is sequences).
Regards,
Lukas