tags:

views:

34

answers:

1

Im getting to grips with the basics of PDO.

However Im trying to get the id of the inserted row, Im using:

$query = $system->db->prepare("INSERT INTO {$this->_table} (name,description) VALUES (:name,:description)");
$query->execute(array('name'=>$name,'description'=>$description));

The tutorials I have come across are regarding transactions, however I am not using transactions!

A: 

You're probably looking for lastInsertId. "Returns the ID of the last inserted row or sequence value".

$insertedId = $system->db->lastInsertId() ;
Fanis
Ah ha thanks! For some reason I was trying to call it on the $query variable.
pondpad