Skip to content

Unable to fetch last inserted ID #19

Open
@GoogleCodeExporter

Description

@GoogleCodeExporter
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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions