I need to get the last inserted product by a user. This is what I've came up with
$query = 'SELECT id
FROM products
WHERE user_id = ?
ORDER BY id DESC
LIMIT 1';
It should work because the id is auto increment. To me though, it feels hacky. Is there a better way to do this?
I can't use mysql_last_insert_id()
or anything like that because I need the last product by a specific user.