Re: Re: DB Sequences
| From: | Joshua Eichorn | Date: | Wed, 17 Jul 2002 20:41:36 +0000 |
| Subject: | Re: Re: DB Sequences | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-1920@lists.php.net to get a copy of this message | ||
Tomas V.V.Cox wrote:
El mié, 17-07-2002 a las 19:12, LIMBOURG Arnaud escribió:-joshua eichornWe 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.