Re: Request for lastID
| From: | (Stig Sæther Bakken) | Date: | Thu, 29 Mar 2001 11:43:19 +0000 |
| Subject: | Re: Request for lastID | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-130@lists.php.net to get a copy of this message | ||
["Colin Viebrock" <colin@easyDNS.com>]
> I would *really* like to suggest the following addition to DB::mysql.php, or
> something like it:
>
> function lastID() {
> if ($this->options['optimize'] == 'portability') {
> return DB_ERROR_UNSUPPORTED;
> }
> return mysql_insert_id($this->connection);
> }
>
>
> mysql_insert_id() is a very highly used PHP function. If we hope to convert
> people to using PEAR's DB, then keeping at least a non-portable version of
> this will save people a *lot* of recoding.
>
> Maybe this functionality can be emulated in the other DBs? I don't know if
> auto_increment fields are specific to MySQL.
Providing an API that is portable and generally usable has a higher
priority for PEAR DB than making it easy to port stuff from MySQL.
Sorry. :-)
If you need auto-increment, you should structure your code to use DB's
sequences. If you want to add database-specific stuff to DB, it'll be
with a smoking gun in your hand over my dead body. ;-)
- Stig
--
Stig Sæther Bakken <ssb@fast.no>
Fast Search & Transfer ASA, Trondheim, Norway