betterCode() PHP 2025

Voting

: one plus five?
(Example: nine)

The Note You're Voting On

webmaster at gamecrash dot net
22 years ago
You could use this to get the last insert id...

CREATE TABLE test (
id serial,
something int not null
);

This creates the sequence test_id_seq. Now do the following after inserting something into table test:

INSERT INTO test (something) VALUES (123);
SELECT currval('test_id_seq') AS lastinsertid;

lastinsertid should contain your last insert id.

<< Back to user notes page

To Top