Browse Source

reverted change of count() signature

tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
8250cfbb0f
  1. 2
      framework/yii/ar/ActiveRelationTrait.php
  2. 2
      framework/yii/data/ActiveDataProvider.php
  3. 6
      framework/yii/db/Query.php
  4. 3
      framework/yii/db/QueryInterface.php

2
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;
/**

2
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);
}
/**

6
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();

3
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.

Loading…
Cancel
Save