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

Store results of subsequents statement executions same as of the first one #2487

Closed
wants to merge 1 commit into from

Conversation

morozov
Copy link
Member

@morozov morozov commented Aug 25, 2016

MysqliStatement stores results ($stmt->store_result()) of only the first statement execution. In case if the statement is stored for further reuse in the application, but some of the statement callers didn't fetch all records from the statement, it's impossible to prepare another new one. Besides that, the results of all consequent statement executions become non-buffered.

$conn = \Doctrine\DBAL\DriverManager::getConnection(array(
    'driver' => 'mysqli',
    'host' => 'localhost',
    'user' => 'user',
    'password' => 'passw0rd',
    'dbname' => 'test',
));

$stmt1 = $conn->prepare('SELECT * FROM accounts');
$stmt1->execute();
$stmt2 = $conn->prepare('SELECT * FROM contacts');
$stmt1->execute();
// things going fine so far, since $stmt1 was executed only once
unset($stmt1, $stmt2);

$stmt1 = $conn->prepare('SELECT * FROM accounts');
$stmt1->execute();
$stmt1->execute(); // ← this is the difference
$stmt2 = $conn->prepare('SELECT * FROM contacts');
// MysqliException: Commands out of sync; you can't run this command now

@morozov morozov force-pushed the mysqli-store-result branch from 94604e9 to 5f7e76d Compare August 26, 2016 01:38
@morozov morozov mentioned this pull request Aug 26, 2016
@morozov
Copy link
Member Author

morozov commented Sep 11, 2016

@Ocramius, @kimhemsoe could you review this one again?

morozov added a commit to morozov/dbal that referenced this pull request Oct 27, 2016
morozov added a commit to morozov/dbal that referenced this pull request Oct 27, 2016
morozov added a commit to morozov/dbal that referenced this pull request Oct 27, 2016
@morozov
Copy link
Member Author

morozov commented Oct 30, 2016

Closing in favor of #2536.

@morozov morozov closed this Oct 30, 2016
@Ocramius Ocramius self-assigned this Oct 31, 2016
morozov added a commit to morozov/dbal that referenced this pull request Jan 14, 2017
morozov added a commit to morozov/dbal that referenced this pull request Jan 14, 2017
morozov added a commit to morozov/dbal that referenced this pull request Jan 25, 2017
Ocramius pushed a commit that referenced this pull request Feb 4, 2017
@Ocramius Ocramius added this to the 2.5.11 milestone Feb 4, 2017
@morozov morozov deleted the mysqli-store-result branch February 4, 2017 21:22
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants