Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 0EFCA63240F for ; Sat, 17 Jan 2009 20:54:22 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40399-06 for ; Sat, 17 Jan 2009 20:54:18 -0400 (AST) X-Greylist: delayed 00:05:49.441758 by SQLgrey-1.7.6 Received: from titania.wxnz.net (titania.wxnz.net [58.28.4.13]) by mail.postgresql.org (Postfix) with ESMTP id 05FA46321A5 for ; Sat, 17 Jan 2009 20:54:18 -0400 (AST) Received: from gonzo (ip-118-90-143-90.xdsl.xnet.co.nz [118.90.143.90]) by titania.wxnz.net (Postfix) with ESMTP id A76441DB80A3 for ; Sun, 18 Jan 2009 13:48:25 +1300 (NZDT) Received: from news by gonzo with local (Exim 4.69) (envelope-from ) id 1LOLpw-00043F-Mt for pgsql-php@postgresql.org; Sun, 18 Jan 2009 13:48:24 +1300 To: pgsql-php@postgresql.org Path: not-for-mail From: Jasen Betts Newsgroups: gmane.comp.db.postgresql.php Subject: Re: PREPARE -> EXECUTE Problem Date: 18 Jan 2009 00:48:24 GMT Organization: Dis (not Dat) Organisation Lines: 31 Message-ID: References: <1232019811.9838.9.camel@localhost.localdomain> NNTP-Posting-Host: localhost Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: reversiblemaps.ath.cx 1232239704 15567 127.0.0.1 (18 Jan 2009 00:48:24 GMT) X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/0.9.9 (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200901/14 X-Sequence-Number: 3969 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