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

Bug fix mysqli transaction function call #870

Closed
ym1623 opened this issue Dec 20, 2017 · 1 comment
Closed

Bug fix mysqli transaction function call #870

ym1623 opened this issue Dec 20, 2017 · 1 comment

Comments

@ym1623
Copy link
Contributor

ym1623 commented Dec 20, 2017

Forgive me for submitting the issue here, and I hope I can make a difference in the future, but since every time I pull a request, I report: continuous-integration / travis-ci / pr - The Travis CI build failed, I do not know why Cause.
The following is a mysqli database bug:
system/Database/MySQLi/Connection.php
#869
public function execute($sql)
{
while($this->connID->more_results())
{
$this->connID->next_result();
if($res = $this->connID->store_result())
{
$res->free();
}
}
return $this->connID->query($this->prepQuery($sql));
}

The MySQL client does not allow you to execute a new query where there are still rows to be fetched from an in-progress query. See Commands out of sync in the MySQL doc on common errors.

You can use mysqli_store_result() to pre-fetch all the rows from the outer query. That will buffer them in the MySQL client, so from the server's point of view your app has fetched the full result set. Then you can execute more queries even in a loop of fetching rows from the now-buffered outer result set.

Or you mysqli_result::fetch_all() which returns the full result set as a PHP array, and then you can loop over that array.

Calling stored procedures is a special case, because a stored procedure has the potential for returning multiple result sets, each of which may have its own set of rows. That's why the answer from @A1ex07 mentions using mysqli_multi_query() and looping until mysqli_next_result() has no more result sets. This is necessary to satisfy the MySQL protocol, even if in your case your stored procedure has a single result set.

@lonnieezell
Copy link
Member

I have the seen the issue you've raised. The errors in Travis are not from your code. If you click on the details next to the Travis error, it'll take you a place where you can investigate the errors happening. Basically, I broke the tests a couple of nights ago and haven't had a chance to fix all of them back up just yet.

Closing this issue since you've already got a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants