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:
nate 2006-12-23 20:36:00 +00:00
parent ebe6bab814
commit a420c70c91

View file

@ -1455,8 +1455,7 @@ class Model extends Overloadable {
* @see Model::findAll
*/
function findCount($conditions = null, $recursive = 0) {
list($data) = $this->findAll($conditions, 'COUNT(*) AS count', null, null, 1, $recursive);
list($data) = $this->findAll($conditions, 'COUNT(' . $this->name . '.' . $this->primaryKey . ') AS count', null, null, 1, $recursive);
if (isset($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.
* @return boolean True if the operation should continue, false if it should abort
*/
function beforeFind(&$queryData) {
function beforeFind($queryData) {
return true;
}
/**