yii数据检索查询

时间:2013-03-06 07:13:04

标签: yii

我有一张桌子tablename:user 列名:namedeptareaactive。我已将一些示例数据添加到数据库中 但是在网格视图上,我想只显示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,
    ));
}

提前致谢

0 个答案:

没有答案