If the PHP mysql extension supposedly does not support transactions such as mysqli, why do I see people using it for online transactions?

I read about mysql transactions, and I got the impression that you had to use mysqli or PDO to create transactions. However, I see all examples of stack exchanges and other sites that use the mysql extension as follows:

mysql_query("START TRANSACTION");
$rollback=0

if (!mysql_query($query1)){
$rollback=1
}

if (!mysql_query($query2)){
$rollback=1
}

if (!mysql_query($query3)){
$rollback=1
}

if ($rollback == 1){
mysql_query("ROLLBACK");
}
else{
mysql_query("COMMIT");
}

What is the difference between executing this method and using special mysqli functions mysqli :: rollback and mysqli :: commit?

In addition, what happens if the php script crashes (IE server crash of my application, etc.), the database server automatically rolls back from the transaction after the set time interval?

, , mysql_query ( "COMMIT" )? ""?

!

+5
1

MySQL .

, , , mysqli. , 1:1 MySQL. PDO, .

, : mysqli for performance and interoperability reasons, it the recommended mysql lib in PHP.

, , mysql_query ( "COMMIT" )? ""?

, , . .

, .

- , InnoDB . - 50 . , , InnoDB, :

1205 (HY000): - ;

+7

All Articles