如何查找我的更新是否成功?我使用where uniqueName = name更新,所以我应该总是只更新0行或1.检查我是否更新了一行的好方法是什么?
bri*_*vis 14
mysql_affected_rows()
将返回受更新影响的行数.
http://us.php.net/manual/en/function.mysql-affected-rows.php
小智 7
真的没办法知道它.比方说,表tbl_numbers(ID,值)的行(1, "1")和(2, "二");
$result1="update tbl_numbers set value='first' where id=1";
Run Code Online (Sandbox Code Playgroud)
如果在if子句中检查$ result1,则返回true,mysql_affected_rows()返回1.
但是,$result2="update tbl_numbers set value='two' where id=2";
如果检查中,如果从句它返回true,mysql_affected_rows $结果2()返回0.
并且,$result3="update tbl_numbers set value='three' where id=3";
如果在if子句中检查$ result3,则返回true,mysql_affected_rows()返回0.
归档时间: |
|
查看次数: |
34888 次 |
最近记录: |