怎么检测是否更新成功 [ 2.0 版本 ]
$model = shop::findOne($id);
$model->name= '名称';
$model->update();
怎么检测是否更新成功?
最佳答案
-
zhoupenghui 发布于 2016-12-07 16:30 举报
$result = $model->update(); if ($result === false) { echo '更新失败'; }
其他 5 个回答
-
-
$model->updateAttributes(['name' => '名称']);
updateAttributes() public method Updates the specified attributes. This method is a shortcut to update() when data validation is not needed and only a small set attributes need to be updated. You may specify the attributes to be updated as name list or name-value pairs. If the latter, the corresponding attribute values will be modified accordingly. The method will then save the specified attributes into database. Note that this method will not perform data validation and will not trigger events. public integer updateAttributes ( $attributes ) $attributes array The attributes (names or name-value pairs) to be updated return integer The number of rows affected.
-
-
-
okokad
注册时间:2016-02-29
最后登录:2017-07-01
在线时长:49小时26分
最后登录:2017-07-01
在线时长:49小时26分
- 粉丝12
- 金钱25
- 威望80
- 积分1315