In PHP, after executing an INSERT statement using mysql_query, the query is successful on the MYSQL console. But how can I use the code to determine whether the statement is successfully executed? The return value of this function found in Baidu is TRUE or FALSE. However, if I execute this function, no matter whether it is TRUE or not, it returns 0 ?... In PHP, after executing an INSERT statement using mysql_query, the query is successful on the MYSQL console. But how can I use the code to determine whether the statement is successfully executed?
The return value of this function found in Baidu is TRUE or FALSE. But if I execute this function, no matter whether it is TRUE or not, it returns 0?
Ask how to judge it!
Reply content:
In PHP, after executing an INSERT statement using mysql_query, the query is successful on the MYSQL console. But how can I use the code to determine whether the statement is successfully executed?
The return value of this function found in Baidu is TRUE or FALSE. But if I execute this function, no matter whether it is TRUE or not, it returns 0?
Ask how to judge it!
Returns the number of affected rows.
Use PDO.
After the insert operation is complete, call $ db-> lastInsertid (); query the id returned by the last insert operation. Or view affected_rows