Saturday, June 25, 2011

Re: habtm

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: