NYCPHP Meetup

NYPHP.org

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

Mitch Pirtle mitchy at spacemonkeylabs.com
Thu Aug 5 21:17:26 EDT 2004


Daniel Convissor wrote:

>Sir Mitch:
>
>On Tue, Aug 03, 2004 at 01:51:28PM -0400, Mitch Pirtle wrote:
>  
>
>>Also, do you know if the other relational databases do that too (DB2, 
>>Oracle, etc.), or is this a PostgreSQL only thing?
>>    
>>
>
>I haven't really paid attention to which DBMS's do what.  I just know that 
>it works.  I'm out of town, so can't research it for you further at this 
>time.
>  
>

Perhaps this is me remembering things from long ago (probably in 
different environments even), and they have since all evolved... But I 
do vaguely remember when you fetched the current value of a sequence, 
some databases automatically incremented the value while others did not; 
and this had to do with some databases allowing you to get the current 
value of a sequence without issuing any DML, and others would 
automatically increment just by you fetching the current value.  *shrug*

>>As long as you are aware that nextID() will increment the sequence, you 
>>are golden.  This is what confused me
>>    
>>
>
>Ah.  I'm not sure what in the docs gave you that impression, but I do 
>realize that there is nothing in the docs clearly indicating exactly how 
>it DOES work.  Before I left, I updated the warning text in the notes 
>section of the intro.  See the new text at
>http://www.appelsiini.net/~tuupola/php/peardoc2/package.database.db.intro-sequences.html
>Also put a link to it on all of the sequence methods's pages.
>  
>

BTW there was nothing in your docs that led me astray, I had assumed 
that before a COMMIT or DML statement you would have the same value in 
the sequence.  Again, this may be historical influences, and therefore 
irrelevant ;-)

I like this a lot, but wonder why you wouldn't try to use the sequences 
that were already in the database?  If I had a PostgreSQL database that 
had a PHP website and wxPython client, then the sequence would obviously 
belong in the database; and having PHP keep it's own 'PHP-only' sequence 
alongside the existing one is not a logical choice, no?

Or were there other technical issues that forced you to go with the 
"%s_seq" route?

Regardless, have safe travels and thanks for IMHO PEAR's greatest 
asset!  ;-)

-- Mitch




More information about the talk mailing list