After php updates mysql to get the number of affected rows an exception resolution occurs

  • 2020-05-30 19:43:08
  • OfStack

We know from manual that the mysql_affected_rows function returns outliers when the data before and after UPDATE is 1,

Here's a handy solution, from the official munual message bdobrica at gmail dot com:
As a solution to the problem pointed in the post reffering to mysql_affected_rows() returning 0 when you are making an update query and the fields are not modified although the query is valid, i'm posting the following function. It is very simple and based on a previous post.
function mysql_modified_rows () { 
$info_str = mysql_info(); 
$a_rows = mysql_affected_rows(); 
ereg("Rows matched: ([0-9]*)", $info_str, $r_matched); 
return ($a_rows < 1)?($r_matched[1]?$r_matched[1]:0):$a_rows; 

PS: because of this little problem, I feel that php is too unclear

Related articles: