GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
When one calls lastInsertId() without any parameters inside a transaction that has not yet been committed, an incorrect value is returned.
$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.
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.
This issue was ported from the ZF2 Jira Issue Tracker at
Known GitHub users mentioned in the original message or comment:
I was the original filer of this bug, back when it was on Jira.