i had gridview with search condition like this
select name from content where parent in (select id_content from content where name like '%text%')
parent refers to id_content in the same table…
how i must set the compare criteria??
this is my model
public function search($merge=null)
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$id_developer =Yii::app()->user->id_developer;
$criteria=new CDbCriteria;
$criteria->compare('t.id_content',$this->id_content,true);
$criteria->compare('t.parent',$this->parent,true);
$criteria->compare('t.date_created',$this->date_created,true);
$criteria->compare('t.date_last_update',$this->date_last_update,true);
$criteria->compare('t.name',$this->name,true);
$criteria->compare('t.desc',$this->desc,true);
$criteria->compare('t.status',$this->status);
$criteria->compare('t.link',$this->link,true);
$criteria->compare('t.version',$this->version,true);
$criteria->compare('t.last_update',$this->last_update,true);
$criteria->compare('t.download_total',$this->download_total,true);
$criteria->compare('t.price',$this->price);
$criteria->compare('t.disc',$this->disc);
$criteria->compare('t.age',$this->age);
$criteria->compare('t.rate_average',$this->rate_average);
$criteria->compare('t.rate_total',$this->rate_total,true);
$criteria->compare('t.shortcode',$this->shortcode,true);
$criteria->compare('t.content',$this->content,true);
$criteria->compare('t.number',$this->number,true);
$criteria->compare('admin.name',$this->id_admin,true);
$criteria->with='admin';
$criteria->compare('developer.name',$this->id_developer,true);
$criteria->with='developer';
$criteria->compare('type.name',$this->id_type,true);
$criteria->with='type';
if($merge!==null)
$criteria->mergeWith($merge);
//$criteria->condition = "t.id_developer = ".$id_developer;
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
my view
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'content-grid',
'dataProvider'=>$model->search($merge),
'filter'=>$model,
'columns'=>array(
array(
'class' => 'CButtonColumn',
'header' => 'Action',
'template'=>'{view}{update}',
),
array(
'name'=>'parent',
'type'=>'raw',
'value'=>'MMS::model("util")->getParent($data->parent)',
),
'name',
'desc',
array(
'name'=>'status',
'value'=>'MMS::model("util")->getStatus($data->status)',
),
'link',
'version',
'last_update',
'download_total',
'price',
'disc',
'age',
//'rate_average',
//'rate_total',
'shortcode',
'content',
'number',
),
)); ?>
my controller
public function actionIndex()
{
$model=new Content('search');
$id_developer =Yii::app()->user->id_developer;
$model->unsetAttributes(); // clear any default values
$merge=new CDbCriteria;
$merge->condition = "t.id_developer = ".$id_developer." and t.id_type = 2";
if(isset($_GET['Content']))
$model->attributes=$_GET['Content'];
$merge->condition = "t.id_developer = ".$id_developer." and t.id_type = 2";
$this->render('admin',array(
'model'=>$model,
'merge'=>$merge,
));
}