Search code examples
phpmysqlauto-incrementfat-free-framework

Getting latest inserted auto-incremented record id using fat-free-framework


I need to get the id(AUTO-INCREMENTED) of latest inserted record in a table. I am using fat-free-framework.

I tried to get the latest id by using

$id = mysql_insert_id();

but it gave me this error

Access denied for user 'root'@'localhost' (using password: NO)

I am accessing database using fat-free-framework and not using traditional php functions. Can any one guide me how to accomplish this ?


Solution

  • Try this code after record inserted

    $id = $db->lastInsertId();