RE: [PEAR] [DB-1.3] Clarification concerning Sequences?
| From: | Matt Friedman | Date: | Thu, 03 Oct 2002 02:12:01 +0000 |
| Subject: | RE: [PEAR] [DB-1.3] Clarification concerning Sequences? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-2421@lists.php.net to get a copy of this message | ||
Sequences are database independent and provide the same functionality as
implementation specific mechanisms such as auto increment. You can more
or less rely on your code to work across different database
implementations if you get your ids from $db->nextId('seqName') -
otherwise you are stuck with whichever database you've used and
switching will be quite tricky.
That's the whole point of the db abstraction layer anyway - to free you
from db specific implementations.
The short answer to your question is yes, they are a replacement. In
mysql's case, you would use your seq numbers instead of the numbers
generated by auto increment.
More generally, you can just use one sequence table for your entire
database. Anytime you need a unique id for any table, just do a call to
$db->nextId('yourSeqName') and you'll have the id you need because it's
guaranteed to be unique.
Matt Friedman
Web Applications Developer
www.SpryNewMedia.com
> -----Original Message-----
> From: oododa [mailto:oododa@sbcglobal.net]
> Sent: Wednesday October 2, 2002 5:56 PM
> To: pear-general@lists.php.net
> Subject: [PEAR] [DB-1.3] Clarification concerning Sequences?
>
> From what I've read in the sequences page in the DB section of the
PEAR
> manual, it seems to be implied that one should NOT use AUTO_INCREMENT
on
> one's tables in a mySQL table, and that instead, one should use
sequences.
> Is this correct? Are sequences a replacement for AUTO_INCREMENT, or
does
> DB
> obtain and use ID information from the table?
>
> --
> O.
>
>
>
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php