Hi,
I'm trying to out a table that contains all the categories with there
respective counts of use in companies.
I drop my habtm relation and make a hasone to the company based on id's.
This works fine, its just when I add count it doesn't get defined or used at
all in the query. Anyone give me any pointers please?
Is my current code.
$this->Category->unbindModel(array('hasAndBelongsToMany'=>array('Company')));
$this->Category->bindModel(array('hasOne'=>array(
'CategoriesCompany'=>array(
'foreignKey'=>false,
'type'=>'INNER',
'conditions'=>array('CategoriesCompany.category_id = Category.id')
),
'Company'=>array(
'foreignKey'=>false,
'type'=>'INNER',
'conditions'=>array(
'Company.id =
CategoriesCompany.company_id'
)))));
$this->Category->find('all', array('COUNT(DISTINCT
Category.category_name) AS cocount'));
Thanks,
Dave
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" 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?hl=en