I am trying to execute my PHP code, which calls two MySQL queries via mysqli, and get the error \"Commands out of sync; you can\'t run this command now\".
Here is th
I ran into this error using Doctrine DBAL QueryBuilder.
I created a query with QueryBuilder that uses column subselects, also created with QueryBuilder. The subselects were only created via $queryBuilder->getSQL()
and not executed. The error happened on creating the second subselect. By provisionally executing each subselect with $queryBuilder->execute()
before using $queryBuilder->getSQL()
, everything worked. It is as if the connection $queryBuilder->connection
remains in an invalid state for creating a new SQL before executing the currently prepared SQL, despite the new QueryBuilder instance on each subselect.
My solution was to write the subselects without QueryBuilder.