logo       

Re: lastInsertId and Postgres: msg#00001

Subject: Re: lastInsertId and Postgres
Hi Teemu,

Zend_Db_Table::insert() returns the last insert ID as its return parameter, so there's no need to call lastInsertId() directly. If for some reason you need to, however, you must supply a table name and primary key name.

Hope that helps,

-Matt

----- Original Message ----- From: "Teemu Välimäki" <teemu.valimaki-X3B1VOXEql0@xxxxxxxxxxxxxxxx>
To: <fw-db-wwOhfgvld6hpLGFMi4vTTA@xxxxxxxxxxxxxxxx>
Sent: Saturday, December 09, 2006 12:57 AM
Subject: [fw-db] lastInsertId and Postgres


Hi all,

I'm running Postgres 8.1, PHP 5.2 and ZF 0.2.0 and I'm having trouble with calling lastInsertId after insert. I've done as instructed at http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.insert however I get the following error

Uncaught exception 'PDOException' with message 'SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "__seq" does not exist'

I also have piece of older code which uses Zend_Db_Table to operate inserts and this works. However, in ZF general list I remember reading that using it is slower and should be avoided. So my questions are, is there something wrong with Postgres settings as it claims sequence does not exists when it in fact does (there's a column with SERIAL) and how should I get the new sequence id?

Thanks!




<Prev in Thread] Current Thread [Next in Thread>