Newbie DB Sequence Question

From: Date: Fri, 19 Mar 2004 04:50:38 +0000
Subject: Newbie DB Sequence Question
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11389@lists.php.net to get a copy of this message
I'm trying to use PEAR-DB for a project that uses MySQL as its database. I've having trouble with sequences. I don't mind so much that they create an additional table, but they don't seem to check what data is in the table (i.e., getting the max id in the table) before being created. For example, if I have an already created table with an autoincrement number up to 25, when the sequence is created by DB it starts it at 1 instead of 26. This makes it almost impossible to use DB with pre-existing tables. That means I can either manually increment the sequence counter to the right place, or have the first 25 insert calls fail. Looking at the code around line 500 of DB/mysql.php, it seems to use the LAST_INSERT_ID function in MySQL and also the PHP mysql_insert_id function. It seems to return the MySQL_insert_id if it isn't zero, implying to me that it's looking to be called after the insert query and not before as stated in the manual. Of course, I really haven't looked at the code too much. Am I missing something obvious? Thanks in advance. Sincerely, Paul Burney <http://paulburney.com/>

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