Re: Re: DB Sequences

From: Date: Sun, 21 Jul 2002 06:07:04 +0000
Subject: Re: Re: DB Sequences
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1941@lists.php.net to get a copy of this message
On Wed, 17 Jul 2002, Joshua Eichorn wrote: > Tomas V.V.Cox wrote: > > >El mié, 17-07-2002 a las 19:12, LIMBOURG Arnaud escribió: > > > > > >>We agree on that, that is the power of sequences. > >> > >>But what about the approach of having a row in a "sequence" table and not in > >>a table ? > >> > >> > >> > > > >Sorry I don't catch the point. Let me explain how the sequence emulation > >for MySQL works. We have one table with only one value on it. The schema > >for that table is: > > > >CREATE TABLE ${seqname} ( > > id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL, > > PRIMARY KEY(id) > >) > > > >Each time you call the $db->nextID() method, you are really updating the > >previous value plus one, and returning it (atomically for avoiding > >concurrency problems). You can create that table according to this > >schema by hand (for the CREATE priviledges problem) or just do a: > > > >$ phpcli -r "include 'DB.php'; > >DB::connect('mysql://..')->createSequence('foo');"; > > > >Well that code only works with ZE2 :-) (if I didn't understand wrong the > >new features). Let's say: > > > >$ phpcli -r "include 'DB.php'; $db = DB::connect('mysql://..'); > >$db->createSequence('foo');"; > > > >Note that this emulates how sequences works. I don't see the need of > >having a table with fileds "sequence name -> value" when you can just > >have that "sequence" table with one value, usable by all your tables. > > > >Please re-elaborate your question if you mean other thing :-) > > > > > >Tomas V.V.Cox > > > > > > > > > I think the point is that, if you have 10 different sequences you end up > with 10 different tables for sequence emulation which, is quite annoying. "Annoying" is very subjective. :-) I think having single tables is handy because it makes it very easy to drop sequences, and it gives less complexity to the code. We can not change the default behaviour of sequences, but we can make the way sequences work runtime configurable, at the expense of some complexity (that I'd really like to avoid unless someone gives me better reasons than annoyance ;-). - Stig

« previous php.pear.general (#1941) next »