Determine if the PHP operation MySQL (Tim pruning) is successful

Source: Internet
Author: User

Recently in the use of the CI framework, but the inside of the database operation is not thinkphp convenient, do not know the database operation feedback information, had to rely on the native method to determine whether the operation of the database success

Determine if PHP operation MySQL (Tim pruning) success, mainly with the help of two functions

1. Mysql_num_rows (data) function returns the number of rows in the result set

2.the Mysql_affected_rows () function returns the number of record rows affected by the previous MySQL operation

Mysql_num_rows (data) is primarily used for select operations, with three cases of return values

1. Return of 0 indicates that the select Gets a value of 0 and does not get any results

2. The return value is NULL, indicating that the previous SELECT statement has an error

3. The return value is greater than 0, indicating the number of rows that meet the criteria

Mysql_affected_rows () is mainly used for INSERT, UPDATE, delete three operations

1. A return value of 0 means that the number of rows affected is 0

2. A return value of 1 indicates a problem with the previous SQL statement

3. The return value greater than 0 indicates the number of rows affected

Determine if the PHP operation MySQL (Tim pruning) is successful

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.