Cgridview Filter And Sql Errore

hello all

i have an CGridView in my admin.php:


$this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'activity-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

            'activity_name',

            array( 'name'=>'activity_type', 'value'=>'$data->getActiveTypeOption()',

            'filter'=>$model->getActivityTypeOptions()),

             array( 'name'=>'stu_search', 'value'=>'$data->getStuName()' ),

             array( 'name'=>'worker_search', 'value'=>'$data->getWorkerName()'),

             array( 'name'=>'day_search', 'value'=>'$data->timetableCode->day'),

             array( 'name'=>'hour_search', 'value'=>'$data->timetableCode->from' ),

		

		array(

			'class'=>'CButtonColumn',

                     'template' => '{update} {delete}',

		),

	),

)); 

a search in my model:


public function search()

	{

		            

                $criteria->with = array('workers');

                $criteria->compare('students.stu_nickname',$this->stu_search,true);

                $criteria->together=TRUE;

              

                $criteria->with = array( 'workers');

                $criteria->compare('workers.worker_nickname',$this->worker_search,true);

                $criteria->together=TRUE;


                $criteria->with = array( 'timetableCode');

                $criteria->compare('timetableCode.day',$this->day_search,true);

                $criteria->together=TRUE;

             

                $criteria->compare('activity_code',$this->activity_code);

		$criteria->compare('timetable_code',$this->timetable_code);

		$criteria->compare('activity_name',$this->activity_name,true);

                $criteria->compare('date_start',$this->date_start,true);

		$criteria->compare('date_end',$this->date_end,true);

		$criteria->compare('activity_type',$this->activity_type,true);

		$criteria->compare('year_of_study',$this->year_of_study,true);

		$criteria->compare('notes',$this->notes,true);


                

		return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

		));

and relations:


public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

			'timetableCode' => array(self::BELONGS_TO, 'Timetable', 'timetable_code'),

			'studentToActivity' => array(self::HAS_MANY, 'StudentToActivity', 'activity_code'),//משמש לשיבוץ של יותר מסטודנט אחד בקבוצה

                        'students' => array(self::MANY_MANY, 'Student','tbl_student_to_activity(stu_code, activity_code)'),//משמש ליצירת הטבלאות

			'tempActivityChanges' => array(self::HAS_MANY, 'TempActivityChange', 'original_activity_code'),

			'workerToActivity' => array(self::HAS_MANY, 'WorkerToActivity', 'activity_code'),

                        'workers' => array(self::MANY_MANY, 'Worker','tbl_worker_to_activity(worker_code, activity_code)'),

                        

		);

	}

the problem is that when i try to filter the student or worker I get this erorr:

“SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘students.stu_nickname’ in ‘where clause’. The SQL statement executed was: SELECT COUNT(DISTINCT t.activity_code) FROM tbl_activity t LEFT OUTER JOIN tbl_timetable timetableCode ON (t.timetable_code=timetableCode.timetable_code) WHERE (students.stu_nickname LIKE :ycp0)”

can’t figure out how to implement a INNER JOIN instead of LEFT OUTER JOIN.

please help me

Hi

Maybe you can try this




$criteria->join = 'LEFT JOIN your_table_name ON t.id = your_table_name.id';

$criteria->compare('your_table_name.attribute',$this->attribute,true);