Re: HABTM Does not select extra table :(
When i set the paginate var in the function it only selects the category data, not the article table :( Function: public function category($category_name) { // Pagination settings $this->paginate = array('limit' => 15, 'page' => 1, 'order'=>array('id' => 'desc'), 'fields' => array('id', 'name')); $this->set('articles', $this->paginate('Category', array('name' => $category_name))); } Category model: public $name = 'Category'; // Table name public $useTable = 'categories'; public $hasAndBelongsToMany = array( 'Article' => array('className'=> 'Article', 'joinTable'=> 'articles_categories', 'foreignKey' => 'article_id', 'associationForeignKey'=> 'category_id', 'conditions' => '', 'order'=> '', 'limit'=> '', 'unique' => true, 'finderQuery' => '', 'deleteQuery' => '', ) ); Result: Array ( [0] => Array ( [Category] => Array ( [id] => 3 [name] => PHP ) [Article] => Array ( ) ) ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: HABTM Does not select extra table :(
Do you mean i have to query the other model inside the article controller.. I tried it like this (using the category model now): function category($category_name) { $this->set('articles', $this->paginate('Category', array('name' => $category_name))); } But then it uses the fields i have set in the article_controller, which are not available in the category :( // Pagination settings var $paginate = array('limit' => 15, 'page' => 1, 'order'=>array('id' => 'desc'), 'fields' => array('id', 'title', 'published', 'frontpage', 'created', 'modified', 'slug', 'menu_id')); On Aug 16, 1:39 am, Grant Cox <[EMAIL PROTECTED]> wrote: > You cannot query across a HABTM like that - the relationships are > generated through multiple SQL queries so your WHERE does not get put > in the right part (and the WHERE is just whatever conditions you > provide - Cake does not understand what you want). > > Instead, query the Menu model, with appropriate recursive set (and > bindModel / unbindModel if needed) to get the associated Articles that > you want. > > On Aug 16, 3:17 am, Mech7 <[EMAIL PROTECTED]> wrote: > > > Nobody :( > > > On Aug 12, 4:51 pm, Mech7 <[EMAIL PROTECTED]> wrote: > > > > Anybody has an idea ? :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: HABTM Does not select extra table :(
Thanks but i am not really sure what you mean by query the menu model ? On Aug 16, 1:39 am, Grant Cox <[EMAIL PROTECTED]> wrote: > You cannot query across a HABTM like that - the relationships are > generated through multiple SQL queries so your WHERE does not get put > in the right part (and the WHERE is just whatever conditions you > provide - Cake does not understand what you want). > > Instead, query the Menu model, with appropriate recursive set (and > bindModel / unbindModel if needed) to get the associated Articles that > you want. > > On Aug 16, 3:17 am, Mech7 <[EMAIL PROTECTED]> wrote: > > > Nobody :( > > > On Aug 12, 4:51 pm, Mech7 <[EMAIL PROTECTED]> wrote: > > > > Anybody has an idea ? :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: HABTM Does not select extra table :(
You cannot query across a HABTM like that - the relationships are generated through multiple SQL queries so your WHERE does not get put in the right part (and the WHERE is just whatever conditions you provide - Cake does not understand what you want). Instead, query the Menu model, with appropriate recursive set (and bindModel / unbindModel if needed) to get the associated Articles that you want. On Aug 16, 3:17 am, Mech7 <[EMAIL PROTECTED]> wrote: > Nobody :( > > On Aug 12, 4:51 pm, Mech7 <[EMAIL PROTECTED]> wrote: > > > Anybody has an idea ? :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: HABTM Does not select extra table :(
Nobody :( On Aug 12, 4:51 pm, Mech7 <[EMAIL PROTECTED]> wrote: > Anybody has an idea ? :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: HABTM Does not select extra table :(
Anybody has an idea ? :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---