When I insert a row, it increments the ID field using SERIAL.
How can I return the newly created ID number right after the insert?
(Database is Postgresql.)
$db->Insert_ID();
This code works nicely:
$insertId = $adodb->getOne("INSERT INTO test (str) values ('test') RETURNING id");
Treat your INSERT the same as a SELECT and use RETURNING in your INSERT-query:
INSERT INTO foo (bar) VALUES('Doe') RETURNING id;
Fetch the result and you're done. Works since version 8.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With