Re: [phplib] Explaination of 'db_swquence' From: nathan r. hruby (nhruby <email protected>)
Date: 05/02/01

on 5/2/01 11:52 AM, Dennis Gearon at gearond <email protected> wrote:

> Would someone give me a brief explanation of the purpose of
> 'db_sequence'?
>

First read: http://phplib.netuse.de/documentation/documentation-3.html#ss3.1
(note the using next_id() subsction at the end of section-3.1)

Make a table called db_sequence

# --------------------------------------------------------
#
# Table structure for table 'db_sequence'
#

CREATE TABLE db_sequence (
   seq_name varchar(127) NOT NULL,
   nextid int(10) unsigned DEFAULT '0' NOT NULL,
   PRIMARY KEY (seq_name)
);

Then add the sequences you want by name (INSERT INTO db_sequence
seq_name='foo', nextid='0');

and then call $idToUse = $db->next_id("foo"); to get an atomic id that will
not be any place else. This is just a kludge around the various versions of
AUTO INCREMENT or whatever sequences that the different databases that
exist.

The nice thing is that you have a record of how your keys are used in other
tables if you set up a seq_name for each table that you use, ie: you can do
a little extra checking for inconsistencies in your tables.

-n

-- 
......
nathan hruby - nhruby <email protected>
computer support specialist
department of drama and theatre
http://www.drama.uga.edu/
......

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>