kfirufk / zend-db-model-generator

Automatically exported from code.google.com/p/zend-db-model-generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to fetch last inserted ID

GoogleCodeExporter opened this issue · comments

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

Original comment by pedrospdc on 18 Feb 2012 at 6:06

  • Changed state: Started