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 <jeffery2k2...@gmail.com> wrote: > 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 <pirkl.lu...@gmail.com> wrote: > > > 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 AS user ON comment.user_id=user.id > > ORDER BY comment.created DESC LIMIT 10 > > > but i don't know how to make it Cake way. > > > On 19 čnc, 18:24, brian <bally.z...@gmail.com> wrote: > > > 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( > > > 'conditions' => array( > > > 'Category.public' => 1 > > > ), > > > 'contain' => array( > > > 'Article' => array( > > > 'fields' => array('Article.id') > > > ), > > > 'Comment' > > > ) > > > ) > > > ); > > > > On Sun, Jul 19, 2009 at 11:37 AM, eXistent<pirkl.lu...@gmail.com> wrote: > > > > > 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 this things. > > > > $this->Comment->find('all',array('conditions'=>array > > > > ('Category.public'=>1)) don't work. > > > > Many thanks for all solutions. > > -- > -- > (¨`•.•´¨) I may be busy, > `•.¸(¨`•.•´¨) but I assure you, > (¨`•.•´¨)¸.•´ you are always in my heart > `•.¸.•´ > > With Lots of Love..... > > THANKS AND REGARDS > > Jeffery Jacob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---