Im trying to get the mysql_insert_id
using PDO.
Thus far i've not found a good example that works with both inserting and updating.
Does anyone have a piece of complete code as example?
If you need $pdo->lastInsertId()
to return the id of the row just updated (I would seriously reconsider my design if I needed it but hey... can be a true need), do the update like this:
UPDATE tablename SET some_column='somevalue',id=LAST_INSERT_ID(id);
PDO::lastInsertId. Returns the ID of the last inserted row or sequence value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With