I am currently performing a Model->query() instead of Model->find() as I can't seem to do a 'count' with 'contains', 'group', 'order' and 'limit' to represent this SQL statement.
$data = $this->Instruction->query("
SELECT `Source`.`company_name`, COUNT(*) AS `count`
FROM `instructions` AS `Instruction`
LEFT JOIN `sources` AS `Source` ON (`Instruction`.`source_id` = `Source`.`id`)
GROUP BY source_id
ORDER BY count DESC
LIMIT 5"
);
Preference would be to perform a Model->find('count') or even a Model->find('all') with the appropriate 'contains', 'group', 'order' and 'limit' but I am having no such luck.
Try this: $options = array(