Req #4418 [Opn->Csd]: Clarification of DB::nextId & sequence reqs

From: Date: Tue, 24 May 2005 15:58:49 +0000
Subject: Req #4418 [Opn->Csd]: Clarification of DB::nextId & sequence reqs
References: 1  Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-6084@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=4418&edit=1 ID: 4418 Updated by: danielc@analysisandsolutions.com Reported By: apthorpe at cynistar dot net -Status: Open +Status: Closed Type: Feature/Change Request Package: Documentation Operating System: All PHP Version: 4.3.4 -Assigned To: +Assigned To: danielc New Comment: The problems you're raising are common sense issues that database developers should know. None the less, I've modified the documentation. The changes should show up on Sunday when the docs get rebuilt. Previous Comments: ------------------------------------------------------------------------ [2005-05-24 10:35:17] apthorpe at cynistar dot net Description: ------------ Based on the current documentation for PEAR DB, regarding sequences: 1. It's not clear that CREATE permission is needed to use DB::nextId($seq_name, $onDemand) when $onDemand is set to TRUE (default.) 2. There are implied limitations on the contents of $seq_name. For example, using $seq_name = 'staff.staff_id' with MySQL will cause the sequence table name to be generated as 'staff.staff_id_seq' - the '.' causes MySQL to interpret 'staff' as the database and 'staff_id_seq' as the table name. In retrospect this is expected, but it's not obvious unless you understand the implemenation of sequences in PEAR::DB. One of three things should happen: 1) special characters in $seq_name should be stripped or encoded, 2) an error should be thrown if $seq_name contains special characters, or 3) the documentation should explicitly suggest safe characters to use in $seq_name, or at least warn against using special characters. 3. DB::nextId() on a existing table will not work if used on a table with IDs that were assigned before nextId() was first used. One must manually set the id column in the sequence table to MAX(id) before using nextId(). While it's doubtful that DB could be made psychic enough to do this automatically, the documentation should warn against using nextId() on an existing table without dumping/reinserting the data using nextId() or adjusting the sequence id manually. Thank you for taking the time to read this and for releasing and maintaining PEAR::DB ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=4418&edit=1

« previous php.pear.doc (#6084) next »