[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pear-general
Subject:    Re: [PEAR] PEAR DB Sequences
From:       Justin Simpson <juan () iamsosmrt ! com>
Date:       2002-10-22 16:38:32
[Download RAW message or body]

The purpose of PEAR::DB is to create an abstraction layer between your
php code and the database you are using.  Autoincrement is a  'feature'
(you say feature, I say bug) of MySQL that doesn't exist in Oracle,
Postgresql, etc. In those two RDBMS environments, if you were working
just in the database, you would create a sequence in sql and set the
default value of the column you want incremented to be the next value of
your sequence.  

However, both of these approaches (creating a sequence in the database,
using autoincrement) are non portable.  If you are going to use those
features, why are you using PEAR::DB? You might as well go back to usig
mysql_connect() and mysql_query() etc.  

PEAR::DB provides its sequence feature to abstract away the differences
in those two approaches.  You use the $db->nextId('myseq') syntax, and
PEAR::DB takes care of the details at the database level for you.  The
end effect is the same as if you had used whatever database specific
syntax your RDBMS uses, but you haven't used any database specific php
code.

Justin Simpson



On Tue, 2002-10-22 at 09:09, Jeff Busby wrote:
> I think i missed the first part of this thread, but can you tell me why it
> would be benefitial to let PEAR::DB create the sequence rather than set to
> the field itself to autoincrement?
> 
> Cheers,
> Jeff.
> 



-- 
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic