query($sql); if ($ r){ echo "The error is that the data has been updated here. If this ai"/> query($sql); if ($ r){ echo "The error is that the data has been updated here. If this ai">

Home >Backend Development >PHP Tutorial >php mysql php mysql How to determine whether it has been updated after update

php mysql php mysql How to determine whether it has been updated after update

WBOY
WBOYOriginal
2016-07-29 08:47:38965browse

First of all, my suggestion is to get over it if you encounter a problem. Read the PHP manual 1001 times and the problem will be solved.
I searched on Baidu, and netizens gave me a variety of answers.
First correct a wrong method from Baidu:

Copy the code The code is as follows:


$sql = "update table a set aname='name' where aid=88";
$r = $conn ->query($sql);
if ($r){
echo "The error is that the data has been updated here. If the data with aid of 88 does not exist, the statement will also return true.";
}


with Even if the where statement does not comply with the adjustment, as long as the sql statement is correct, it will still return true. The true here can be understood as the sql statement does not make an error. It has the same effect as writing like this: $conn->query($sql) or die("Update An error occurred, please check whether the parameters are correct. ");.
To get the number of rows updated by update, use: mysql_affected_rows($conn) or mysqli_affected_rows($conn)

The above introduces the method of php mysql php mysql to determine whether it has been updated after update, including the content of php mysql. I hope it will be helpful to friends who are interested in PHP tutorials.

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