Re: Idea for pear sequence tables

From: Date: Wed, 24 Sep 2003 07:13:07 +0000
Subject: Re: Idea for pear sequence tables
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-21920@lists.php.net to get a copy of this message
Apologies for the slow reply to this thread, just finished a very busy contract. Regarding putting all sequences in a single table, I'm glad this is being discussed and that the concept has been accepted in principal, when you have 30+ tables in a DB the additional sequences are a real mess :-) Browsing through Drupal code a few weeks ago I came up with a simple solution that may help progress towards a patch. They use a procedural function for the mysql driver that: - takes care of table locking - using REPLACE creates a new sequence when one does not exist It's a bit of a hack, but I converted the function to class named DB_mysql_XXX that has a single nextId method. This class is used to override the default mysql driver for PEAR::DB and is called like: $conn = & DB::connect("DB_mysql_XXX://user:pass@host/dbName"); After initial testing, it appears to work as expected, with the advantage that the DB library can be updated without interfering with the 'hack'. Code attached. cheers Demian Nola Stowe wrote: > Good point ... but boss says "I'm still partial to section-specific > sequences, though, just so each group of numbers remains in a manageable > range. We do have to type them manually from time to time." > > <sigh> > > >>-----Original Message----- >>From: Tomas V.V.Cox [SMTP:cox@idecnet.com] >>Sent: Friday, September 12, 2003 11:36 AM >>To: Stowe, Nola >>Cc: pear-dev@lists.php.net >>Subject: Re: [PEAR-DEV] Idea for pear sequence tables >> >>On Friday, September 12, 2003 17:52, Stowe, Nola wrote: >> >> >>>I'm sure someone has thought of this and you have a good reason for NOT >>>doing it.. but..I'm curious on why you didn't do it this way? >> >>>Instead of having another table created for each table I need a sequence >> >>on, >> >>>what about having a sequence table (seq_name, seq_key) with rows for >> >>each >> >>>table and then just fetching and updating that table with the next key? >> >>Well, a sequences is just that a pool of unique id's for using in your >>tables. I never understood why one would like to have multiple >>sequences, while just one for all your tables is enough. >> >>-- >> Tomas V.V.Cox >> mailto:cox@idecnet.com >> >> > > > <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> > The information in this email and any attachments may contain > confidential information that is intended solely for the > attention and use of the named addressee(s). This message or > any part thereof must not be disclosed, copied, distributed or > retained by any person without authorization from the addressee. > If you are not the intended addressee, please notify the sender > immediately, and delete this message. > > <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

« previous php.pear.dev (#21920) next »