An example Analysis of the return value of the number of mysqli_affected_rows Action rows in PHP
This article mainly introduces "the case analysis of the return value of the number of mysqli_affected_rows lines in PHP". In the daily operation, I believe that many people have doubts in the case analysis of the return value of the number of mysqli_affected_rows lines in PHP. Xiaobian consulted all kinds of data and sorted out a simple and easy-to-use operation method. I hope it will be helpful for you to answer the doubt of "the case analysis of the return value of the number of mysqli_affected_rows lines in PHP". Next, please follow the editor to study!
The number of rows affected by update operations in mysqli can be returned in two ways:
1. Returns the number of matching rows
two。 Returns the number of rows affected
By default, the value returned by mysqli_affected_rows is the number of rows affected. If we need to return a matching number of rows, we can initialize the database connection using the mysqli_real_connect function and add the following to the function's flag parameter bit:
MYSQLI_CLIENT_FOUND_ROWS return number of matched rows, not the number of affected rows
Normal format:
The copy code is as follows:
Int mysqli_affected_rows (mysqli link)
Oop format:
The copy code is as follows:
Class mysqli {
Int affected_rows
}
Take a look at the example:
In normal mode, the code is as follows:
The copy code is as follows: