Commit fb3b2f2c by Qiang Xue

Fixes #2490: `yii\db\Query::count()` and other query scalar methods now properly…

Fixes #2490: `yii\db\Query::count()` and other query scalar methods now properly handle queries with GROUP BY clause
parent 0e023f53
......@@ -116,6 +116,7 @@ Yii Framework 2 Change Log
- Enh #2417: Added possibility to set `dataType` for `$.ajax` call in yii.activeForm.js (Borales)
- Enh #2436: Label of the attribute, which looks like `relatedModel.attribute`, will be received from the related model if it available (djagya)
- Enh #2415: Added support for inverse relations (qiangxue)
- Enh #2490: `yii\db\Query::count()` and other query scalar methods now properly handle queries with GROUP BY clause (qiangxue)
- Enh: Added support for using arrays as option values for console commands (qiangxue)
- Enh: Added `favicon.ico` and `robots.txt` to default application templates (samdark)
- Enh: Added `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue)
......
......@@ -356,7 +356,14 @@ class Query extends Component implements QueryInterface
$this->limit = $limit;
$this->offset = $offset;
if (empty($this->groupBy)) {
return $command->queryScalar();
} else {
return (new Query)->select([$selectExpression])
->from(['c' => $this])
->createCommand($db)
->queryScalar();
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment