From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-php@postgresql.org
Subject: Re: PREPARE -> EXECUTE Problem
Date: 18 Jan 2009 00:48:24 GMT
Message-ID: <gktu8o$f6f$1@reversiblemaps.ath.cx> (raw)
References: <1232019811.9838.9.camel@localhost.localdomain>
On 2009-01-15, F. <dev001@pas-world.com> wrote:
> >Just ignore the default.
> >Have you set up the table with SERIAL?
> >if so this should work:
>
> After some changes, for the moment seems the good choice.
> But have a problem getting pdo->lastInsertId(), do not work in postgre
> for me.
>
> I am using this :
> select currval('table_id_seq');
>
do this
select nextval('table_id_seq');
before you insert, and insert the value that gives.
this solves your other problem (use of DEFAULT) too, (or is that the
same problem)
another option is to use 'RETURNING id' when you insert
INSERT
INTO "mytable" ( "thatcolumn" )
VALUES ( 'whatever' )
RETURNING "id";
this needs PG >= 8.2
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: jasen@xnet.co.nz
Subject: Re: PREPARE -> EXECUTE Problem
In-Reply-To: <gktu8o$f6f$1@reversiblemaps.ath.cx>
References: <1232019811.9838.9.camel@localhost.localdomain> <gktu8o$f6f$1@reversiblemaps.ath.cx>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox