pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: PREPARE -> EXECUTE Problem
2+ messages / 2 participants
[nested] [flat]
* Re: PREPARE -> EXECUTE Problem
@ 2009-01-15 11:43 F. <dev001@pas-world.com>
0 siblings, 1 reply; 2+ messages in thread
From: F. @ 2009-01-15 11:43 UTC (permalink / raw)
To: pgsql-php
>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');
Any clear method?
--
--
Publicidad http://www.pas-world.com
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: PREPARE -> EXECUTE Problem
@ 2009-01-18 00:48 Jasen Betts <jasen@xnet.co.nz>
parent: F. <dev001@pas-world.com>
0 siblings, 0 replies; 2+ messages in thread
From: Jasen Betts @ 2009-01-18 00:48 UTC (permalink / raw)
To: pgsql-php
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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2009-01-18 00:48 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-01-15 11:43 Re: PREPARE -> EXECUTE Problem F. <dev001@pas-world.com>
2009-01-18 00:48 ` Jasen Betts <jasen@xnet.co.nz>
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