DbQuery: Let the DbConnection do the count query
This commit is contained in:
parent
9af25acf38
commit
7b6ca0826b
|
@ -212,6 +212,18 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count all rows of the result set
|
||||||
|
*
|
||||||
|
* @param DbQuery $query
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function count(DbQuery $query)
|
||||||
|
{
|
||||||
|
return $this->dbAdapter->fetchOne($query->getCountQuery());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve an array containing all rows of the result set
|
* Retrieve an array containing all rows of the result set
|
||||||
*
|
*
|
||||||
|
|
|
@ -297,7 +297,7 @@ class DbQuery extends SimpleQuery
|
||||||
{
|
{
|
||||||
if ($this->count === null) {
|
if ($this->count === null) {
|
||||||
Benchmark::measure('DB is counting');
|
Benchmark::measure('DB is counting');
|
||||||
$this->count = $this->db->fetchOne($this->getCountQuery());
|
$this->count = parent::count();
|
||||||
Benchmark::measure('DB finished count');
|
Benchmark::measure('DB finished count');
|
||||||
}
|
}
|
||||||
return $this->count;
|
return $this->count;
|
||||||
|
|
Loading…
Reference in New Issue