j4mie / idiorm

A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.
http://j4mie.github.com/idiormandparis/
2.01k stars 369 forks source link

id() after save is not working #113

Closed neohunter closed 11 years ago

neohunter commented 11 years ago

I have this:

            $d = ORM::for_table('person')->create();
            $d->name = 'hola';
    $d->save();

    $id = $d->id();
    var_dump($id); // string(0) ""

Table is innoDB, latest version of idiorm, primary key field is 'id'

treffynnon commented 11 years ago

Can you please post the schema of your table?

neohunter commented 11 years ago

Found the error,

Was because I was setting

   $d->id = ''; 

before save().

treffynnon commented 11 years ago

Thank you for letting me know and I am glad you found the bug in your code, but please do supply an accurate code sample when posting issues to open source projects. There is no way I could of helped you with the redacted sample you provided. A maintainer must be able to reproduce the problem to be able to help you.