سؤال

there is anyway to change the result of a query, I have several columns in my database's table with 1 and 0 values, but the 1s and 0s have meaning , let's say 1=Can Jump 0=Don't jump,

I make to query using the code below, and it will gives me back the columns with the 0s and 1s, there is anyway easy to change this values to can jump / dont jump , I'm guessing like an filter or something....

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,
        ));
    }
هل كانت مفيدة؟

المحلول

You can do this by using the afterFind function in your model:

public function afterFind() {
    $this->driveable == '1' ? 'Yes' : 'No';
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top