Re: PREPARE -> EXECUTE Problem

Re: PREPARE -> EXECUTE Problem

am 15.01.2009 12:43:30 von devel

>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


--
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Re: PREPARE -> EXECUTE Problem

am 18.01.2009 01:48:24 von Jasen Betts

On 2009-01-15, F. 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

--
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php