Hello,

Having trouble figuring out how to construct a query such as this:

"SELECT products.*, groups.* FROM products Inner Join collections ON
products.collection_id = collections.id Inner Join groups ON
collections.group_id = groups.id WHERE products.name LIKE '%" .
$searchstring . "'"

Products belongsTo Collections and Collections belongsTo Groups

I'm trying to use find all with conditions and fields and recursive,
but no luck.  Example:

            $this->set('products', $this->Product->find('all', array
('contain' => array('Collection', 'Group'), 'conditions'=>array
('Product.name LIKE ' => $searchstring), 'recursive'=>3, 'fields' =>
array('Product.name','Collection.name', 'Collection.group_id',
'Collection.group_id','Group.name') )));

but, the error is:
Warning (512): SQL Error: 1054: Unknown column 'Group.name' in 'field
list' [CORE/cake/libs/model/datasources/dbo_source.php, line 512]

How can I obtain the Group field data through Collections when
querying Products?

Todd

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to