Data Provider Relation

Guardian model:(relation)

'studentsGuardians' => array(self::HAS_MANY, 'StudentsGuardian', 'guardian_id'),

Student model relation:

'studentsGuardians' => array(self::HAS_MANY, 'StudentsGuardian', 'student_id'),

Students Guardian model relation:

'guardian' => array(self::BELONGS_TO, 'Guardian', 'guardian_id'),

			'student' => array(self::BELONGS_TO, 'Student', 'student_id'),

Now in controller i want to select those students whose guardian_id=id but my code select all records without filtering. my code is

public function actionAssignGuardian($id)



            $dataProvider = new CActiveDataProvider('Student',


                                    'criteria' => array(



                                            array('with'=>array('guardian','condition'=>' guardian_id=:id',









            $this->renderPartial('Pages/_assignGuardian', array(

                'dataProvider' => $dataProvider,




Kindly point me to correct way that how could i select those students whose guardian_id= given id in function.


You probably need to add an ‘INNER JOIN’.

However, may get other side effects - that is why I use my RelatedSearchBehavior extension.