Monday, December 29, 2008

findCount different then find('count')

So I noticed when I used find('count') that the query is wrong:

SELECT COUNT(*) AS `count` FROM `friends` AS `Friend` LEFT JOIN
`users` AS `User` ON (`Friend`.`user_id` = `User`.`id`) WHERE 1 = 1

But when I use findCount the query and results are correct:

SELECT COUNT(*) AS `count` FROM `friends` AS `Friend` WHERE
((`Friend`.`user_id` = 2) OR (`Friend`.`friend_id` = 2))

Is this a bug, or are they supposed to do separate things, or am I
doing the find('count') incorrectly?

This is the conditions im passing:

$conditions = array('OR' => array(
'Friend.user_id' => $user_id,
'Friend.friend_id' => $user_id
));
--~--~---------~--~----~------------~-------~--~----~
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: