Simply getting LAST_INSERT_ID;
<?php
// Note: waiting for "select" part from pg_query below.
// Note: separating the query parts using semicolons (;).
$qry = pg_query("
INSERT INTO users (id,uname,upass,rep) VALUES (DEFAULT,'bubu','a981v',0.19);
SELECT Currval('users_id_seq') LIMIT 1
");
// or
$qry = pg_query("
INSERT INTO users (id,uname,upass,rep) VALUES (DEFAULT,'bubu','a981v',0.19) RETURNING Currval('users_id_seq')");
$fch = pg_fetch_row($qry);
print_r($fch);
?>
Array
(
[0] => 3 -> Gotcha!
)