-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Error on queryOne after execute #3695
Comments
can you please post the complete stack trace of the error? |
|
try add this code before execute your command \Yii::$app->db->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); |
MDMunir, can you explain for what? I found something, but I can't check it now.
yii\db\Command::execute doesn't close cursor: public function execute()
{
$sql = $this->getSql();
$rawSql = $this->getRawSql();
Yii::info($rawSql, __METHOD__);
if ($sql == '') {
return 0;
}
$token = $rawSql;
try {
Yii::beginProfile($token, __METHOD__);
$this->prepare();
$this->pdoStatement->execute();
$n = $this->pdoStatement->rowCount();
Yii::endProfile($token, __METHOD__);
return $n;
} catch (\Exception $e) {
Yii::endProfile($token, __METHOD__);
$this->db->getSchema()->handleException($e, $rawSql);
}
} |
i just read your exception message and try to give you a solution. i dont know, my solution will work or not. if doesnt work, i am sory. $db = \Yii::$app->getDb();
$db->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
$cmd = $db->createCommand('SET @tmp1 = 1; SET @tmp2 = 2;');
$cmd->execute();
$result = $db->createCommand('SELECT @tmp1, @tmp2;')->queryOne(); |
I see what you mean, but to solve the problem we need to understand the reason. |
I am unable to reproduce this. |
Closed, since there is no response from the author. |
When I run the following code:
I get the error:
But when I use:
or
It works fine.
The text was updated successfully, but these errors were encountered: