PHP-MySQLi-Database-Class
PHP-MySQLi-Database-Class copied to clipboard
Get id of the last updated row ?
I was looking as this https://stackoverflow.com/questions/1388025/how-to-get-id-of-the-last-updated-row-in-mysql#answer-1751282 . How to execute it ?
I have done :
$sql = 'SET @scanning_id := 0;'.
'UPDATE mytable '.
'SET status = "true", '.
'id = (SELECT @scanning_id := id) '.
'WHERE param = "asdf" LIMIT 1; '.
'SELECT @scanning_id;';
$id = $db->rawQuery($sql);
I get the error :
PHP Fatal error: Uncaught Exception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE mytable SET status = "true", id = (SELECT @scanning_id := id) WHERE hr' at line 1 query: SET @id := 0; UPDATE mytable SET status = "true", id = (SELECT @scanning_id := id) WHERE params = "asdf" LIMIT 1; SELECT @scanning_id; in PHP_MySQLi_Database/MysqliDb.php:2006
Is it possible to run raw unprepared queries ?
Only method insert() can return last_id. method update() only return status update (check is: "$db->count" )