无论如何要改变查询的结果,我的数据库表中有几列有1和0值,但是1和0有意义,假设1 =可以跳0 =不跳,< / p>
我使用下面的代码进行查询,它会给我回到0和1的列,无论如何很容易改变这个值可以跳/不跳,我猜是像过滤器或什么的....
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,true);
$criteria->compare('result',$this->result,true);
$criteria->compare('p_city',$this->p_city,true);
$criteria->compare('p_state',$this->p_state,true);
$criteria->compare('d_city',$this->d_city,true);
$criteria->compare('d_state',$this->d_state,true);
$criteria->compare('type',$this->type,true);
$criteria->compare('date_search',$this->date_search,true);
$criteria->compare('date_shipped',$this->date_shipped,true);
$criteria->compare('driveable',$this->driveable,true);
$criteria->compare('enclosing',$this->enclosing,true);
$criteria->compare('type_service',$this->type_service,true);
$criteria->order='date_search desc';
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
答案 0 :(得分:0)
您可以使用模型中的afterFind
功能执行此操作:
public function afterFind() {
$this->driveable == '1' ? 'Yes' : 'No';
}