我编辑了我的模型->搜索功能的条件,只查看具有相同业务 ID 的数据,但现在高级搜索不起作用。
这是我模型上的代码 model->search()
public function search() {
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria;
$criteria->compare('LOVEAGENT_ID', $this->LOVEAGENT_ID);
$criteria->compare('FIRST_NAME', $this->FIRST_NAME, true);
$criteria->compare('LAST_NAME', $this->LAST_NAME, true);
$criteria->compare('DOB', $this->DOB, true);
$criteria->compare('PASSWORD', $this->PASSWORD, true);
............
$criteria->condition = 'BUSINESS_ID=:businessID';
$criteria->params = array(':businessID' => Yii::app()->user->businessId);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
));
}
我的管理员控制器:
public function actionAdmin() {
$model = new LoveAgentContactDetails('search');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['LoveAgentContactDetails'])) {
$model->attributes = $_GET['LoveAgentContactDetails'];
}
$this->render('admin', array(
'model' => $model,
));
}
和 Cgrid 视图设置在视图:
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'love-agent-contact-details-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
'FIRST_NAME',
'LAST_NAME',
'lastLoginTime',
'created',
array(
'class' => 'CButtonColumn',
),
),
));