@WebRenovator: Jesse had his condition correct, you only need to omit
the => when you are comparing one column to another like when
associating two models and specifying conditions.
array('Model1.model2_id = Model2.id')
for conditions with operators such as LIKE, !=, <= etc. Cake is clever
enough to know to remove the = sign it normally adds.
@Jesse: The problem lies in paginating the Category model because
Category hasMany Item it will run the category query first then run a
separate query for the multiple items, therefore Item.name does not
exist to place a condition on.
The easy answer is to paginate Item instead as Item belongsTo Category
the item model will run just one query joining both tables allowing
you to specify conditions on both the tables if required.
$this->set('items', $this->paginate('Item', array('Category.id'=>1,
'Item.name LIKE' => '%the%')));
Not sure why you would be running a text search for item name but only
retrieving categories, but if you really need to do that then you
would have to force a hasOne join from Category to Item by unbinding
the hasMany and replacing it with a hasOne.
http://book.cakephp.org/view/86/Creating-and-Destroying-Associations-on-the-Fly
HTH
Paul.
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