Greetings,
Has anyone out there transitioned an existing app from using the
mysql_* functions in PHP to PEAR DB?
I'm re-writing an existing PHP application, and I'm required to utilize
PEAR's DB class as the database layer. Currently, the application is
using the mysql_* functions to access the database and the primary
key/identity column is using AUTO_INCREMENT to calculate the id for
each record in several tables.
I realize that PEAR doesn't provide direct access to the last insert id
(like I could get with mysql_insert_id()), and instead utilizes the
sequences facility to emulate AUTO_INCREMENT (I'm assuming this is to
provide similar functionality to some engines that don't have
AUTO_INCREMENT). So, I need to have a seamless way to transition from
using the AUTO_INCREMENT.
In experimenting, I've seen that when creating a sequence, PEAR DB
creates a table named {$sequence_name}_seq and that table contains a
single record with a single column that contains the last used sequence
id.
So, let's assume I have a table called item_master, and I'm going to
utilize a sequence I'm going to name item_master as well. Normally PEAR
would create an item_master_seq table and keep track of the unique ID
in that table. When I implement the new code, can I just create a
item_master_seq table in the production database with the appropriate
characteristics, update the record in that table to the next available
id for the item_master table, and then turn off AUTO_INCREMENT on the
table? In experimenting, this appears to be the case, but since I'm
going to updating a production application, but I want to be absolutely
sure this isn't going to cause any unforseen problems before I do this.
Thanks in advance,
Jeremy
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php