Searching

Search not working in some place

in modal:-


	public function search()

	{

		// @todo Please modify the following code to remove attributes that should not be searched.


		$criteria=new CDbCriteria;


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

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

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

                $criteria->compare('c.c_name',  $this->Course , true);

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

                $criteria->compare('l.book',  $this->Book, true);

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


		return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

		));

	}

in admin:-


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

	'id'=>'student-grid',

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

	'filter'=>$model,

	'columns'=>array(

		'id',

		'name',

		array(

                        'name'=>'Course','value'=>'$data->c->c_name'

                    ),

		array(

                        'name'=>'Book','value'=>'$data->l->book'

                    ),

		'email',

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>

but search is working for name id email but it is not working for book and course.




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

                $criteria->compare('c.c_name',  $this->Course , true);

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

                $criteria->compare('l.book',  $this->Book, true);



you overwrite "with" of criteria (first you assign array with "c" then you overwrite it with array with "l")

should be rather one assignment of array(ā€˜cā€™, ā€˜lā€™)

Yaa i do the correction .Now it is working for Course but not for Book Issued what should i do