mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Optimizing findCount() query, and adding beforeFind() reference fix for Ticket #1693
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4165 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ebe6bab814
commit
a420c70c91
1 changed files with 2 additions and 3 deletions
|
@ -1455,8 +1455,7 @@ class Model extends Overloadable {
|
||||||
* @see Model::findAll
|
* @see Model::findAll
|
||||||
*/
|
*/
|
||||||
function findCount($conditions = null, $recursive = 0) {
|
function findCount($conditions = null, $recursive = 0) {
|
||||||
|
list($data) = $this->findAll($conditions, 'COUNT(' . $this->name . '.' . $this->primaryKey . ') AS count', null, null, 1, $recursive);
|
||||||
list($data) = $this->findAll($conditions, 'COUNT(*) AS count', null, null, 1, $recursive);
|
|
||||||
|
|
||||||
if (isset($data[0]['count'])) {
|
if (isset($data[0]['count'])) {
|
||||||
return $data[0]['count'];
|
return $data[0]['count'];
|
||||||
|
@ -1859,7 +1858,7 @@ class Model extends Overloadable {
|
||||||
* @param array $queryData Data used to execute this query, i.e. conditions, order, etc.
|
* @param array $queryData Data used to execute this query, i.e. conditions, order, etc.
|
||||||
* @return boolean True if the operation should continue, false if it should abort
|
* @return boolean True if the operation should continue, false if it should abort
|
||||||
*/
|
*/
|
||||||
function beforeFind(&$queryData) {
|
function beforeFind($queryData) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue