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.