The specific examples are as follows:
03 |
$conn = mysql_connect (' localhost ', ' root ', '); |
04 |
mysql_select_db (' Test ', $conn); |
05 |
mysql_query ("SET NAMES GBK"); |
08 |
The table that supports the transaction must be a InnoDB type |
09 |
Only one occurrence of a transaction can occur: |
10 |
mysql_query (' Start TRANSACTION ');/start transaction |
11 |
mysql_query (' ROLLBACK ');/ROLLBACK TRANSACTION |
12 |
mysql_query (' commit ');/COMMIT Transaction |
14 |
If multiple rollback transactions occur in a transaction, when a transaction is committed, all operations on the database are canceled only before the first rollback to the start of the transaction, and all the database operations are still valid until the transaction is committed for the first rollback, so the rollback statement is typically placed only before the transaction statement is committed |
15 |
If there is no commit statement for a transaction, all of the following database operations are performed from the start of the transaction (the execution method returns a right error) but have no effect on the database, but the previous segment is automatically committed when the next start transaction statement is executed |
17 |
mysql_query (' START TRANSACTION '); |
20 |
$ins _testtable1 = "INSERT into Testtable1 (name,age) VALUES (' 23"); |
21st |
if (!mysql_query ($ins _testtable1)) { |
24 |
Error inserting statement field name |
25 |
$ins _testtable2 = "INSERT into Testtable1 (name,ages) VALUES (' second ', ' 24 ')"; |
26 |
if (!mysql_query ($ins _testtable2)) { |
31 |
mysql_query (' ROLLBACK '); |
33 |
mysql_query (' COMMIT '); |