NYCPHP Meetup

NYPHP.org

[nycphp-talk] PEAR::DB->nextID problems

Daniel Convissor danielc at analysisandsolutions.com
Tue Aug 3 12:39:14 EDT 2004


Hi Mitch:

On Tue, Aug 03, 2004 at 12:17:51PM -0400, Mitch Pirtle wrote:
> 
> Here was the misunderstanding, and 
> hopefully you could add something to the docs to clarify?
> 
> nextID() grabs the next value from the sequence, AND THEN INCREMENTS 
> THAT SEQUENCE.

A couple thoughts off the top of my head... I think the behavior may 
vary between DBMS's.  Also, all the system is meant to do is provide a 
unique number, not necessarily a specific number, so it doesn't really 
matter what the number is.


> So you cannot get a value from nextID() and then do an 
> insert without specifying that value for the column that the sequence 
> is used for.

A quick look at your test script shows you're using the PostgreSQL's 
native serial (which is like auto_increment to you MySQL'ers out 
there) and PEAR DB's sequence data.  Use one or the other.  Using both 
leads to the problems you're seeing, let alone, the duplication of 
information.


> Providing an example 
> in the docs would be a time saver and avoid unnecessary forehead 
> slapping.  ;-)

http://pear.php.net/manual/en/package.database.db.intro-sequences.php 
has an example.  Are you saying it's too terse / not real-world 
enough?

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list