// try to find a row
$model = someModel::find()
...
->one();
// if exist a row, return the model
// otherwise return null
// now check if the model is null
if (is_null($model)) {
$model = new someModel();
}
// apply your change
$model->attributes = $attributes;
...
// insert or update
$model->save();
YII Insert or Update a Row
最新推荐文章于 2021-10-21 08:19:25 发布