//命名空间 use app\components\HttpException; model废除方法relations(),scopes() Yii::app() 修改成 Yii::$app $this->render('/' . $this->id, array('orders' => $orderSearch)) 修改成 return $this->render('/' . $this->id, array('orders' => $orderSearch)) throw new THttpException('抱歉,您没有权限修改!'); 修改成 throw new HttpException('抱歉,您没有权限修改!'); Campaign::model()->getAll(); 修改成 \app\models\Campaign::find()->all(); Cjson::encode($array); 修改成 \yii\helpers\Json::encode($array); public function beforeSave(){ parent::beforeSave(); } 修改成 public function beforeSave($insert){ parent::beforeSave($insert); } public function afterSave() { parent::afterSave(); } 修改成 public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if($insert) { //这里是新增数据 } else { //这里是更新数据 } } public function tableName() { return 'v_report_ads'; } 修改成 public static function tableName() { return 'v_report_ads'; } $criteria = new CDbCriteria; .... $models = Adgroup::model()->findAll($criteria); 修改成 $query = \app\models\Adgroup::find(); ... $models = $query->all();