Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to fetch last inserted ID #19

Open
GoogleCodeExporter opened this issue Oct 13, 2015 · 1 comment
Open

Unable to fetch last inserted ID #19

GoogleCodeExporter opened this issue Oct 13, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Create a model
2. Save an model object to the db
3. Try to fetch the ID

What is the expected output? What do you see instead?
I'd want a way to get the last inserted ID. Usually, when using DBTables the 
return of a save method is the ID itself, although, using ZDMG generated 
models, the mapper returns true instead of the last inserted ID. This can be 
changed by adding setting the $success var with the PK on the mapper, like this:
if ($primary_key) {
     $model->setId($primary_key);
     $success = $primary_key;

What version of the product are you using? On what operating system?
0.6, using Ubuntu Linux 11.10, PHP5.3, MySQL 14.14

Please provide any additional information below.
Using $model->getMapper()->getDbTable()->getAdapter()->lastInsertId() returns 
0, and i'm not being able to run the method from the dbtable object itself.

Original issue reported on code.google.com by pedrospdc on 9 Feb 2012 at 2:18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant