This is the situations:
A Cart belongsTo Product. A Product belongsTo a Category.
This is my query:
$results = $this->Cart->find('all', 
        array(
          'contain' => array(
                'Product' => array('Category')
                 ),
          'conditions'=>array(
                               'OR' => array(
                                    'Product.title LIKE' => "%$query%", 
                                    'Category.name LIKE' => "%$query%"
                                     )
                             ),                                                  
          'fields'=>array('Product.title', 'Category.name'))
debug($results); exit;
The query no work !! Look at this:
 Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Category.name' in 'field list'
SQL Query: SELECT `Product`.`title`, `Category`.`name`, `Product`.`id` FROM `my_db`.`carts` AS `Cart` LEFT JOIN `my_db`.`products` AS `Product` ON (`Cart`.`product_id` = `Product`.`id`) WHERE ((`Product`.`title` LIKE '%apple%') OR (`Category`.`name` LIKE '%apple%')) 
As you can see the Category data aren't attached to the Product !! If I try the same query with a simple condition (eg. 'Category.name LIKE' => "%$query%") the query works !! So I think that the problem is with the OR condition , but i'm unable to solve it ...
Have suggestions ?
Thx in advance
 
                        
Since you're trying to OR between terms on different tables, I believe you'll have to throw out your relationship for this query and make a manual join instead. With the manual join, I think you should be able to write conditions how you want. Perhaps something like this?