Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commands out of sync #2430

Closed
lemartin opened this issue Jun 29, 2016 · 7 comments
Closed

Commands out of sync #2430

lemartin opened this issue Jun 29, 2016 · 7 comments

Comments

@lemartin
Copy link

Hello,

when running the following code I get this error.

PHP Fatal error:  Uncaught exception 'Doctrine\DBAL\Driver\Mysqli\MysqliException' with message 'Commands out of sync; you can't run this command now'
$stmt1 = $connection->prepare("SELECT * FROM information_schema.TABLES");
$stmt1->execute();
$stmt1->closeCursor();

$stmt1->execute();

$stmt2 = $connection->prepare("SELECT * FROM information_schema.VIEWS");
$stmt2->execute();

If $stmt1 is only executed once, the error does not occur. My guess is, that is is related to $this->_stmt->store_result(), which is only called the first time when MysqliStatement::execute is executed, because the second time $this->_columnNames is initialised (see. Doctrine\DBAL\Driver\Mysqli\MysqliStatement).

In commits 10a96cc and d00511c it was changed when store_result() is called. Before these commits, it was called when $this->_columnNames was initialised, now it is only called when $this->_columnNames is being initialised.

The main question is, was this intentionally and, is there a way to circumvent the problem?

No, closing the $stmt1 after the second execute is not really an option.

We are using doctrine/dbal 2.5.4 on PHP 5.4.45 with MySQL 5.5.

@deeky666
Copy link
Member

deeky666 commented Jun 29, 2016

I don't quite get what your example is trying to achieve? Why the second execute()? What is it supposed to do? AFAIK we do not support executing a prepared statement more than once. I am not even sure all PHP drivers support this.

@kimhemsoe
Copy link
Member

kimhemsoe commented Jun 29, 2016

PDO supports it seems http://php.net/manual/en/pdostatement.closecursor.php

I haven't looked if would be possible for mysqli driver to support it. How close do we follow PDO in these cases?

@deeky666
Copy link
Member

@kimhemsoe we (should) support what it is defined in our interface contracts (as much as possible). Looks like we adopted the contract from PDO here, so basically it means we should support it where possible. I would suggest adding a failing test case for this is DBAL first and then start to fix the implementations.

@kimhemsoe
Copy link
Member

👍

@morozov
Copy link
Member

morozov commented Aug 26, 2016

I would suggest adding a failing test case for this is DBAL first and then start to fix the implementations.

@deeky666 please see #2487.

@morozov
Copy link
Member

morozov commented Oct 30, 2021

Must have been fixed by #2546.

@morozov morozov closed this as completed Oct 30, 2021
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants