The correct way to get the last inserted id, when using mysql_*
is to make a call to mysql_insert_id()
.
What you are reading is partially correct - mysql_insert_id
is in the process of being deprecated, but it's not just that function. All mysql_*
functions are being deprecated. Instead you should use either PDO or mysqli_*
.
In your code snippet, it is unclear which database access library you are using. Since your calls seem to be bound to an object, it is likely you are using PDO or mysqli.
For PDO you can use PDO::lastInsertId
.
For mysqli
, use mysqli->insert_id
.