Search code examples
phpyiiattributesupdatemodel

how to update model in yii using specific attributes?


I have a model called DisnotificationUpdate. Primary key in the table is id.

public function attributeLabels()
    {
        return array(
            'id' => 'ID',
            'notifi_id' => 'Notifi',
            'view' => 'View',
            'userid' => 'Userid',
        );
    }

I want to update the table using userid attribute (eg: update DisnotificationUpdate set view='1' where userid='c01') How can I do this in yii?


Solution

  • DisnotificationUpdate::model()->updateAll(array('view'=>1),'userid=:uid',array(':uid'=>$uid));