Determine whether the php operation for mysql (add deletion and modification check) is successful

Source: Internet
Author: User
Determine whether php is successfully operating mysql (add, delete, modify, and query) using the CI framework recently. However, the database operations in this framework are not convenient for ThinkPhp and do not know the feedback of database operations, the native method is used to determine whether the database operation is successful.

Determine whether the php operation on mysql is successful (addition, deletion, modification, and query) by using two functions

1. number of rows in the returned result set returned by the mysql_num_rows (data) function

2. the mysql_affected_rows () function returns the number of records affected by the previous MySQL operation.

Mysql_num_rows (data) is mainly used for select operations. There are three possible return values.

1. if the returned result is 0, the value obtained by select is 0. no results are obtained.

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

3. the returned value is greater than 0, indicating the number of rows that meet the condition.

Mysql_affected_rows () is mainly used for insert, update, and delete operations.

1. if the returned value is 0, the number of affected rows is 0.

2. the returned value is-1, indicating a problem with the previous SQL statement.

3. if the returned value is greater than 0, it indicates the number of affected rows.

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.