From 8250cfbb0f1b3b87ba1ed901c8d38bf1b92bdcfb Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 14 Nov 2013 08:06:57 +0100 Subject: [PATCH] reverted change of count() signature --- framework/yii/ar/ActiveRelationTrait.php | 2 +- framework/yii/data/ActiveDataProvider.php | 2 +- framework/yii/db/Query.php | 6 +++--- framework/yii/db/QueryInterface.php | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/framework/yii/ar/ActiveRelationTrait.php b/framework/yii/ar/ActiveRelationTrait.php index 6b617bc..d87b22d 100644 --- a/framework/yii/ar/ActiveRelationTrait.php +++ b/framework/yii/ar/ActiveRelationTrait.php @@ -33,7 +33,7 @@ trait ActiveRelationTrait * @var array the columns of the primary and foreign tables that establish the relation. * The array keys must be columns of the table for this relation, and the array values * must be the corresponding columns from the primary table. - * Do not prefix or quote the column names as they will be done automatically by Yii. + * Do not prefix or quote the column names as this will be done automatically by Yii. */ public $link; /** diff --git a/framework/yii/data/ActiveDataProvider.php b/framework/yii/data/ActiveDataProvider.php index a8bb18f..0943be4 100644 --- a/framework/yii/data/ActiveDataProvider.php +++ b/framework/yii/data/ActiveDataProvider.php @@ -158,7 +158,7 @@ class ActiveDataProvider extends BaseDataProvider throw new InvalidConfigException('The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.'); } $query = clone $this->query; - return (int) $query->limit(-1)->offset(-1)->orderBy([])->count($this->db); + return (int) $query->limit(-1)->offset(-1)->orderBy([])->count('*', $this->db); } /** diff --git a/framework/yii/db/Query.php b/framework/yii/db/Query.php index 0ae5f44..50ed105 100644 --- a/framework/yii/db/Query.php +++ b/framework/yii/db/Query.php @@ -179,13 +179,13 @@ class Query extends Component implements QueryInterface /** * Returns the number of records. - * @param Connection $db the database connection used to generate the SQL statement. - * If this parameter is not given (or null), the `db` application component will be used. * @param string $q the COUNT expression. Defaults to '*'. * Make sure you properly quote column names in the expression. + * @param Connection $db the database connection used to generate the SQL statement. + * If this parameter is not given (or null), the `db` application component will be used. * @return integer number of records */ - public function count($db = null, $q = '*') + public function count($q = '*', $db = null) { $this->select = ["COUNT($q)"]; return $this->createCommand($db)->queryScalar(); diff --git a/framework/yii/db/QueryInterface.php b/framework/yii/db/QueryInterface.php index d13fa2b..f3cc312 100644 --- a/framework/yii/db/QueryInterface.php +++ b/framework/yii/db/QueryInterface.php @@ -44,11 +44,12 @@ interface QueryInterface /** * Returns the number of records. + * @param string $q the COUNT expression. Defaults to '*'. * @param Connection $db the database connection used to execute the query. * If this parameter is not given, the `db` application component will be used. * @return integer number of records */ - public function count($db = null); + public function count($q = '*', $db = null); /** * Returns a value indicating whether the query result contains any row of data.