I have three tables:
- Content (id)
- ContentCategory (id_content, id_category)
- Category (id)
Content Relations
'Categories' => array(self::MANY_MANY, 'Category', 'ContentCategory(id_content, id_category)'), 'category' => array(self::HAS_MANY, 'Category', 'id'),
I need to get all Content entries that have a specific category (in CActiveDataProvider for use in CListView).
When I use findAll (), I get the records I want (works),
$model=Content::model()->with(array( 'Categorieses'=>array( 'condition'=>'id_category=1', ), ))->findAll();
But when I work with CActiveDataProvider, I get all the entries in the Content (not those that have a certain category - it does not work)
$dataProvider=new CActiveDataProvider('Content', array( 'pagination'=>array('pageSize'=>15), 'criteria'=>array( 'with'=>array( 'Categories'=>array( 'condition'=>'id_category=1', ), ), ), ) );
How can i do this?
Thanks a lot!
source share