mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
Fix #17881: yii\db\Query::queryScalar() wasn’t reverting the select, orderBy, limit, and offset params if an exception occurred
This commit is contained in:
@ -461,13 +461,25 @@ class Query extends Component implements QueryInterface, ExpressionInterface
|
||||
$this->orderBy = null;
|
||||
$this->limit = null;
|
||||
$this->offset = null;
|
||||
$command = $this->createCommand($db);
|
||||
|
||||
$e = null;
|
||||
try {
|
||||
$command = $this->createCommand($db);
|
||||
} catch (\Exception $e) {
|
||||
// throw it later
|
||||
} catch (\Throwable $e) {
|
||||
// throw it later
|
||||
}
|
||||
|
||||
$this->select = $select;
|
||||
$this->orderBy = $order;
|
||||
$this->limit = $limit;
|
||||
$this->offset = $offset;
|
||||
|
||||
if ($e !== null) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $command->queryScalar();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user