PHPBuilder - get insert ID from PostgreSQL

RSS Twitter

get insert ID from PostgreSQL

by: NIkolay Mihaylov
April 17, 2002

Version: .1

Type: Sample Code (HOWTO)

Category: Databases

License: GNU General Public License

Description: Mysql has it, why doesn't PG? This lets you do the same thing.

<? /*
This is not a code exactly, code it yourself:

create sequence x_seq;

create table x(
    a int4 not null default nextval('x_seq'),
    b char(10)

create unique index x_pk on x(a);

in php.

first execute a query and get result:

$x=value_of_this("select nextval('x_seq') as x"); //will not work if you copy paste it

then exec full sql:

insert into x values($x, 'somedata');

use $x ...

*/ ?>

Comment and Contribute

Your comment has been submitted and is pending approval.

NIkolay Mihaylov



(Maximum characters: 1200). You have characters left.