ZF-12484: PgSQL lastInsertId() incorrect in a transaction

Issue Type: Bug Created: 2012-12-06T18:28:27.000+0000 Last Updated: 2013-04-05T16:07:07.000+0000 Status: Closed Fix version(s): Reporter: Vestigal (vestigal) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db

  • database
  • postgres,
  • postgresql

Related issues: Attachments:


When one calls lastInsertId() without any parameters inside a transaction that has not yet been committed, an incorrect value is returned.

To reproduce:

<pre class="highlight">
$this->insert(); // We assume that the table has a primary key named 'id' that is automatically incremented.
var_dump($this->getAdapter()->lastInsertId()); // Returns false

If one calls lastInsertId() with both parameters, then the correct value is returned. I.E.

<pre class="highlight">
var_dump($this->getAdapter()->lastInsertId($this->_name, 'id')); // Prints a number, like 23, which is what we would expect.

I tested this using Postgres, but it could be an issue in other adapters, as well.


Posted by Ralph Schindler (ralph) on 2013-04-05T16:07:07.000+0000

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit:

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.