Commit 8250cfbb by Carsten Brandt

reverted change of count() signature

parent 1acdbb74
......@@ -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;
/**
......
......@@ -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);
}
/**
......
......@@ -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();
......
......@@ -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.
......
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