Tuesday, September 1, 2009

Get Counts

Cakephp provides the function to get the count of a query with:
$this->Model->find("count")

Also I have noticed that cakephp fires the count query to each query
that i execute.

Questions:
1. Is it because of the Pagination component/helper?
2. How to get the result of the Count query?

Here are the two queries:
SELECT COUNT(*) AS `count` FROM `conferences` AS `Conference`
LEFT JOIN `venues` AS `Venue` ON (`Conference`.`venue_id` =
`Venue`.`id`)
WHERE `Conference`.`date` >= '2009-09-01 21:37:35'
AND `Conference`.`status` = 1

SELECT * FROM `conferences` AS `Conference`
LEFT JOIN `venues` AS `Venue` ON (`Conference`.`venue_id` =
`Venue`.`id`)
WHERE `Conference`.`date` >= '2009-09-01 21:37:35'
AND `Conference`.`status` = 1
ORDER BY `Conference`.`date` ASC
LIMIT 20

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: