Home Page » Active Record » MANY_MANY Criteria problem
0
Votes
MANY_MANY Criteria problem
hi.
I have many_many relation.
Categories & Articles.
Just now I want create data provider for CListVeiw Articles where category id =5;(e.g)
But my code gives all the Articles (( Please help!
- $criteriaItem = new CDbCriteria();
- $criteriaItem->with = array(
- 'Categories' => array(
- 'condition' => 'Categories.id = :cat_id',
- 'params' => array(':cat_id' => $categoryID)
- )
- );
- $articleItems = new CActiveDataProvider('Article', array(
- 'criteria' => $criteriaItem,
- 'pagination' => array(
- 'pageSize' => Y::param('blogItemSize', 5),
- 'pageVar' => 'page',
- ),
- ));
$criteriaItem = new CDbCriteria();
$criteriaItem->with = array(
'Categories' => array(
'condition' => 'Categories.id = :cat_id',
'params' => array(':cat_id' => $categoryID)
)
);
$articleItems = new CActiveDataProvider('Article', array(
'criteria' => $criteriaItem,
'pagination' => array(
'pageSize' => Y::param('blogItemSize', 5),
'pageVar' => 'page',
),
));Thanks all.
By eibrahimov in Active Record · Asked 390 days 23 hours 30 mins ago
Questions: 4 Accepted: 0 ( 0% ) | Reputation: 0
Possibly related Questions
-
many_many relation using Giix extension
October 19, 2011 By Puigcerber 9 Answers
TAGS
actioncreate ( x 2 )ACTIVERECORD ( x 4 )AJAX ( x 10 )ajaxSubmitButton ( x 4 )AR ( x 2 )cactivedataprovider ( x 2 )CActiveForm ( x 2 )cactiverecord ( x 2 )CGridView ( x 14 )CJuiAutoComplete ( x 3 )CJuiDialog ( x 8 )CListView ( x 8 )controller ( x 7 )Css ( x 2 )CStarRating ( x 2 )CTreeView ( x 2 )database ( x 5 )dialog ( x 2 )dropdownlist ( x 3 )EGMaps ( x 3 )extension ( x 3 )file ( x 2 )form ( x 6 )Giix ( x 2 )gridview ( x 2 )html ( x 2 )javascript ( x 3 )many_many ( x 4 )merge ( x 2 )model ( x 4 )Modules ( x 3 )multilanguage ( x 2 )php ( x 2 )redirect ( x 4 )Registration ( x 3 )relations ( x 5 )renderPartial ( x 8 )session ( x 2 )sorting ( x 3 )sql ( x 4 )url ( x 3 )urlManager ( x 3 )validation ( x 3 )yii ( x 11 )YiiAnswers Site ( x 4 )This website counts Questions and 429 Answers by 8456 registered users.

You can try add ‘together’=>true
By SpiLLeR · 370 days 19 hours 20 mins ago
Questions: 0 Accepted: 0 ( 0% ) | Reputation: 0