I want to get id of current inserted row after executing insertion query.
p.s.: I'm using postgresql database.
I want to get id of current inserted row after executing insertion query.
p.s.: I'm using postgresql database.
In PG7 it was pg_last_oid, the docs there explain pretty clearly how to get the last id from newer version of PG.
If we assume that by "id" you mean a column which is primary key and also is declared SERIAL then you need to add a RETURNING to the INSERT statement:
INSERT INTO <table> (...) VALUES (...) RETURNING id;
And in PHP you can treat this statement as a normal query which returns one row.
From the Postgres documentation
Insert a single row into table distributors, returning the sequence number generated by the DEFAULT clause:
INSERT INTO distributors (did, dname) VALUES (DEFAULT, 'XYZ Widgets') RETURNING did;
http://www.postgresql.org/docs/8.3/interactive/sql-insert.html