mysqli_affected_rows 与 mysqli_num_rows的不同之处
2017-05-01 15:56
344 查看
来源于http://stackoverflow.com/questions/25555758/what-is-the-difference-between-mysqli-affected-rows-and-mysqli-num-rows
问题如下:
问题如下:
down votefavorite | The PHP docs for mysqli_num_rows says Returns the number of rows in the result set. The PHP docs for mysqli_affected_rows says Returns the number of rows affected by the last INSERT, UPDATE, REPLACE or DELETE query. _num_rows is called on a result, and _affected_rows is called on a connection. Since I think they do the same thing(correct this assumption if I'm wrong), I'm wondering whether one works better than the other, and which situations would call for which function. Aren't number of rows affected and number of rows in the result set synonymous? 解答如下:
num_rowstells you how many rows there are in the result set you just selected with a SELECTquery. affected_rowstells you how many rows where affected by an INSERT, UPDATE, REPLACEor DELETEquery. The difference is obvious: $resultSet = mysqli_query($c, 'SELECT ...'); echo mysqli_num_rows($resultSet); SELECTresult set goes into num_rows. mysqli_query($c, 'UPDATE ...'); echo mysqli_affected_rows($c); No result set, no num_rows. |
0down votefavorite | The PHP docs for mysqli_num_rows says Returns the number of rows in the result set. The PHP docs for mysqli_affected_rows says Returns the number of rows affected by the last INSERT, UPDATE, REPLACE or DELETE query. _num_rows is called on a result, and _affected_rows is called on a connection. Since I think they do the same thing(correct this assumption if I'm wrong), I'm wondering whether one works better than the other, and which situations would call for which function. Aren't number of rows affected and number of rows in the result set synonymous? |
相关文章推荐
- mysql_affected_rows()和mysql_num_rows()
- mysql_num_rows()和mysql_affected_rows()的作用和区别(新浪)
- num_rows和count(*)的值为何不同?
- PHP函数mysql_affected_rows()与mysql_num_rows()有什么区别?
- dba_tables表中的num_rows与count(*)的值为何不同
- PHP中mysql_affected_rows()和mysql_num_rows()区别
- php的数据库函数中mysql_fetch_row、mysql_affected_rows、mysql_num_rows的区别
- PHP中mysqli_affected_rows作用行数返回值分析
- mysql_num_rows()与mysql_affected_rows()的用法
- mysql_num_rows(),mysql_fetch_row(),mysql_affected_rows的区别
- Use mysql_num_rows() to find out how many rows were returned for a SELECT statement or mysql_affected_rows() to find out how man
- PHP中mysqli_affected_rows作用行数返回值分析
- PHP函数mysql_affected_rows()与mysql_num_rows()有什么区别?
- mysql_num_rows和mysql_affected_rows所带的参数不一样
- php中mysql_affected_rows()返回-1带来的“陷阱”
- PHP mysql_num_rows() 函数,统计数据库行目
- mysql_affected_rows
- echo mysql_affected_rows() 返回0
- num_rows 不显示值
- Solution for Store update, insert, or delete statement affected an unexpected number of rows (0)