I'm getting an (SQLSTATE[HY000]: General error) trying to run the following query using PDO to MySQL.
$updateQuery = "UPDATE user SET email = '$email', id = LAST_INSERT_ID(id) WHERE other_id = '$otherId';
SELECT LAST_INSERT_ID() as updated_id;"
$user = $connection->query($updateQuery);
$user->setFetchMode(PhDb::FETCH_ASSOC);
$userRec = $user->fetchAll();
I understand that normally Update queries don't return anything so therefore the widely accepted solution is to not attempt to return the results.
However as you can see I am returning the last updated row ID and the query works correctly when I directly query the DB.
Is this a PDO bug?