-1

我有一个表tablename:user 列名称:name, dept, area, active. 我已经在数据库中添加了一些示例数据但是在网格视图中我只想显示具有活动 =1 的列的数据谁能帮我在查询中添加这个条件,我正在使用 mysql 数据库

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(
    //'reports_to' => array(self::BELONGS_TO, 'Student', 'id'),
    );
}

public function attributeLabels()
{
    return array(
        'user_id' => 'User',
        'user_name' => 'User Name',
        'userpass' => 'Userpass',
        'userdept' => 'Userdept',

    );
}

public function search()
{
    // Warning: Please modify the following code to remove attributes that
    // should not be searched.

    $criteria=new CDbCriteria;

    $criteria->compare('user_id',$this->user_id,true);
    $criteria->compare('user_name',$this->user_name,true);
    $criteria->compare('userpass',$this->userpass,true);
    $criteria->compare('userdept',$this->userdept,true);
    $criteria->compare('reports_to',$this->reports_to,true);

    return new CActiveDataProvider($this, array(
        'criteria'=>$criteria,
    ));
}

提前致谢

4

0 回答 0