$number = 1000;
$field = 'PV';
$WeiPageId = 2;
if ($number == 0 || !in_array($field, ['PV', 'UV'])) return false;
$model = self::find()
->where(['WeiPageId' => $WeiPageId])
->one();
$model->$field = $model->$field + $number;
$res = $model->save();
刚用Yii2 写了一段代码,感觉这样做字段的自增也不错