Home >Backend Development >PHP Tutorial >php mysql method to determine whether it has been updated after update_PHP tutorial

php mysql method to determine whether it has been updated after update_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:22:02904browse

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 mistake 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 "Error thought Here the data has been updated. If the data with aid of 88 does not exist, the statement will still return true. ";
}

The statement with where will be the same even if it does not meet the adjustment as long as the sql statement is correct. Return true. The true here can be understood as the SQL statement does not have an error. It has the same effect as writing like this: $conn->query($sql) or die("Update error, 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)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324760.htmlTechArticleFirst 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 of all, correct a mistake made by Baidu...
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