ConFoo Montreal 2026: Call for Papers

Voting

: zero plus one?
(Example: nine)

The Note You're Voting On

qeremy [atta] gmail [dotta] com
13 years ago
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!
)

<< Back to user notes page

To Top