Hey folks,
I've been away from cakePHP lately, but finally I've stopped reinventing the wheel and just went back to cakePHP. Let me say I am proud of it and I love it again!
Since I was gone, cake's improved and I definitely like it.
Anyway, I've came up with a problem which obviously should be simple to fix.
So I have this function in my CarTemplatesController which should find me all required db fields and count children.
function index(){
// $aTemplates = $this->CarTemplate->find('all', array('fields' => array('CarTemplate.*', 'COUNT(CarTemplateCategory.id)')));
$aTemplates = $this->CarTemplate->query("SELECT `CarTemplate`.*, COUNT(CarTemplateCategory.id) FROM `car_templates` AS `CarTemplate` LEFT JOIN `car_template_categories` AS `CarTemplateCategory` ON `CarTemplate`.`id` = `CarTemplateCategory`.`car_template_id`");
$this->set(compact('aTemplates'));
}
Unfortunately, the commented find() does not get me the data I require, but causes a SQL error instead.
My CarTemplate hasMany CarTemplateCategory, but my CarTemplateCategory does NOT belongsTo CarTemplate (which I don't think causes the trouble *confused*)
So, in theory cake should build a proper query and return me a COUNT(CarTemplateCategory.id) but it does not, sadly :(
Am I missing something obvious in here?
Thanks in advance,
Faifas
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Friday, August 28, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment