Re: Difficult query with find method

2009-07-20 Thread eXistent
Yes I try it. Because model category don't know model user i modify it to: this->Comment->Article->Category->find( 'all', array( 'conditions' => array( 'Category.public' => 1 ), 'contain' => array(

Re: Difficult query with find method

2009-07-20 Thread brian
There's nothing in that query specifying that the Category should be public. Anyway, did you try the statement I posted? If you need User as well, change to: $this->Comment->Article->Category->find( 'all', 'array( 'conditions' => array( 'Categor

Re: Difficult query with find method

2009-07-20 Thread eXistent
I know about that but I wonder if it can be done otherwise. The Cake way with find method is more beautiful :-) On 20 čnc, 12:26, jeff wrote: > use > > $this->modelname->query(" SQL STAEMENT HERE "); > > OR > > use this link for further study > > http://book.cakephp.org/view/456/query > > > > On

Re: Difficult query with find method

2009-07-20 Thread jeff
use $this->modelname->query(" SQL STAEMENT HERE "); OR use this link for further study http://book.cakephp.org/view/456/query On Mon, Jul 20, 2009 at 3:53 PM, eXistent wrote: > > I need it for report of new comments, but only from articles inside > public category. > In SQL way it looks lik

Re: Difficult query with find method

2009-07-20 Thread eXistent
I need it for report of new comments, but only from articles inside public category. In SQL way it looks like this: SELECT * FROM comments AS comment LEFT JOIN articles AS article ON comment.article_id=article.id LEFT JOIN categories AS category ON article.category_id=category.id LEFT JOIN users

Re: Difficult query with find method

2009-07-19 Thread brian
Are you sure you want to find all Comments based on a Category? Wouldn't it make more sense to find Comments based on Article (through Articles based on Category)? Anyway, you should be able to do (from CommentsController): $this->Comment->Article->Category->find( 'all', 'array(

Difficult query with find method

2009-07-19 Thread eXistent
Hi, I have a Comment, Article, Category models. Category has many articles and articles mas many comments. And category have boolean atribut public. I want to find all comments (with limit 10) whitch belongs to articles witch belongs to category with public = true. I don't know how to tell cake th