Re: PREPARE -> EXECUTE Problem

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: PREPARE -> EXECUTE Problem
Дата
Msg-id gktu8o$f6f$1@reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на Re: PREPARE -> EXECUTE Problem  ("F." <dev001@pas-world.com>)
Список 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

В списке pgsql-php по дате отправления:

Предыдущее
От: "F."
Дата:
Сообщение: Re: PREPARE -> EXECUTE Problem
Следующее
От: Raymond O'Donnell
Дата:
Сообщение: PHP 5.8 -> Postgres on Win2003