Hello folks, I'm trying to figure out how to get the last inserted ID from my database. The query runs but instead of getting the actual number inserted, I get the word Array returned. Here's the code, let me know how to fix this. Thanks! For what its worth, this is MySQL running PHP and the DB connection I believe is PDO.
Code:
$query = $db->prepare("SELECT id from orders ORDER BY id DESC LIMIT 1");
$query->execute();
$order_number = $query->fetch();
$order_number++;
Comment