The InnoDb data table of mysql supports transaction, that is, it is successful only when a series of operations are successful. Otherwise, the data is returned to the state of all the uncommitted data. This is useful when it comes to data involving money. The following describes the specific practices in php. mysql InnoDb data tables (& quot; begin & quot;); $ mysql support transactions, that is to say, if a series of operations are supported successfully, the operation is successful. Otherwise, the system returns to the status of all the data that has not been submitted. This is useful for data involving money. The following describes the specific practices in php,
Mysql_query ("begin"); $ rs1 = mysql_query ("insert into cd_test (uname, age) values ('A', 1 )"); $ rs2 = mysql_query ("insert into cd_test (uname, agef) values ('CC', 'CD ')"); // if ($ rs1 & $ rs2) {mysql_query ("COMMIT"); // submit and confirm echo "added successfully ";} else {mysql_query ("ROLLBACK"); // roll back echo "failed to add";} mysql_query ("end ");