Re: postgres - mysql last_inserted_id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx> 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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux