2016-12-07 16:23:44 3400次浏览 6条回答 0 悬赏 10 金钱

$model = shop::findOne($id); $model->name= '名称'; $model->update();
怎么检测是否更新成功?

最佳答案

  • 回答于 2016-12-07 17:54 举报

    自己写个ajax吧,然后通过ajax获取result的结果,在前台显示。

  • 回答于 2016-12-07 20:43 举报
    $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.
    
  • 回答于 2016-12-07 22:15 举报
    $model->updateAttributes(['name' => '名称']);
    
  • 回答于 2016-12-08 13:11 举报

    update 是有返回值的

  • 回答于 2016-12-08 16:10 举报

    用update()的返回值写个判断就行了

您需要登录后才可以回答。登录 | 立即注册
okokad
经理

okokad

注册时间:2016-02-29
最后登录:2017-07-01
在线时长:49小时26分
  • 粉丝12
  • 金钱25
  • 威望80
  • 积分1315

热门问题