Re: postgres - mysql last_inserted_id

From: Date: Fri, 01 Jul 2005 09:27:51 +0000
Subject: Re: postgres - mysql last_inserted_id
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-217961@lists.php.net to get a copy of this message
Hi I'm migrating also to posgresql. The easyest way to manage incrementation with postgres is to use sequences. How to : Create a sequence for each table that need autoincrementation. use pgMyAdmin, to make all needed changes before any insert call the id. select nextval('tablename_seq'); and pass this id to your insert. if you used a database wrapper like PEAR::DB it is easy cause it integrate a function to perform it, and those function are auto-portable. The sequence management is the most common incrementation system across all sgbd. Few like to make the mess like mysql, and sqlite (maybe other than I don't know). regards david Le Thu, 30 Jun 2005 20:55:52 +0200, Uroš Kristan <uros.kristan1@siol.net> a écrit:
Hello, I have an application in production, build on mysql database. I decided to migrate to postgres because of numerous reasons. Can you guys please guide me into the right direction? the main problem is the missing autoincrement of pgsql and getting the last record from the tabel, for linking to another tabel. How do you deal with that? also, can you please recommend me some good manual, explanation or book to help me with this problem. Because the application uses around 250 tables in mysql and I would like to make it righ t the first time when migrating to pgsql.. I was thinking about using the pear db wrapper class, but Regards, Uroš KRISTAN


« previous php.general (#217961) next »