Thanks. I changed the relation to get the exact query. But, now I am having problem with "requestAction" which uses tags controller. I think it is because I have used false in the bind and unbind.
Is it permanently changing the association between models? On Sat, Jun 25, 2011 at 2:36 PM, Andras Kende <and...@kende.com> wrote: > > > http://book.cakephp.org/view/1045/Creating-and-Destroying-Associations-on-the-Fly > > Removing or adding associations using bind- and unbindModel() only works > for the *next* find operation only unless the second parameter has been > set to false. If the second parameter has been set to *false*, the bind > remains in place for the remainder of the request. > > try: > > $this->Post->unbindModel(array('hasAndBelongsToMany'=>array('Tag')), > false); > > > > this is because paginate first does a count query ... > > > Andras Kende > http://www.kende.com > > > On Jun 25, 2011, at 3:14 AM, Prabha Vathi wrote: > > Hi, > > I m not able to get good example for habtm. > I tried something. > $this->Post->unbindModel(array('hasAndBelongsToMany'=>array('Tag'))); > $this->Post->bindModel( > array( > 'hasOne'=>array( > 'PostsTag'=>array( > 'foreignKey'=>false, > 'type'=>'INNER', > 'conditions'=>array('PostsTag.post_id = Post.id') > ), > 'Tag'=>array( > 'foreignKey'=>false, > 'type'=>'INNER', > 'conditions'=>array( > 'Tag.id = PostsTag.tag_id' > ) > ) > ) > ) > ); > $posts = $this->Post->find('all', array('group' => array('Post.id'))); > //working > Find all works, if i add conditions. > But if i comment find and add the following line it is not working. > $this->paginate = array('conditions' => array('Post.status' => > 'active','Tag.tag_machine_value' => $name),'limit' => 2,'group' => > array('Post.id')); //not working > > Any Idea? > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > -- -- Prabhavathi -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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