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

判断更新是否成功

WBOY
Release: 2016-06-07 11:45:46
Original
1772 people have browsed it

如何判断一个更新操作是否成功
$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元

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template