Home  >  Article  >  php教程  >  判断更新是否成功

判断更新是否成功

WBOY
WBOYOriginal
2016-06-07 11:45:461732browse

如何判断一个更新操作是否成功
$Model = D('Blog');<br> $data['id'] = 10;<br> $data['name'] = 'update name';<br> $result = $Model->save($data);<br> if ( false !== $result ){<br>     $this->success('更新成功!');<br> }else{<br>     $this->error('更新失败!');<br> }需要用 !== false 来判断更新是否成功,因为save方法返回值是更新操作影响的记录数,有可能影响的记录数为0,但却更新成功的。

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn