PHP update MySQL After the impact of the number of rows to get the exception to resolve _php tips

Source: Internet
Author: User
We know from the manual that the Mysql_affected_rows function returns an exception value when the data is the same before and after the update.

Here is a convenient solution, from the official munual to see bdobrica at gmail dot com message:
As a solution to the "problem pointed in the" Post reffering to Mysql_affected_rows () returning 0 then are making an upd Ate query and the fields are not modified although the query is valid, I ' m posting the following function. It is very the simple and based on a previous post.
Copy Code code as follows:

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 this little problem for a long time, I feel that PHP is too unclear
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.