> It seems a bad idea to me to do it like this from a performance point
> of view. A findAll() fetches all rows from the database, while a
> count(*) in the database returns only one row with the count.
umm, yes, it would be a bad thing - however, this is probably
happening anyway because of the 'hasMany' and 'belongsTo' association.
Unless you disable the associations with unbindModel or by setting
recursive to 0, you might as well use the existing data, rather than
run an extra findCount on the Comments model.
if you find it slow, then you do want to look into using unbindModel
so you're not returning hundreds of records for each post.
// this line turns off the hasMany asssociation
$this->Post->unbindModel (array('hasMany'=>array('Comment')));
// this line turns off all associations
$this->Post->recursive = -1;
hth,
jon
--
jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---