views:

212

answers:

1

How do I set the isolation level of a transaction to 'SERIALIZABLE' in PHP using mysqli? I have looked everywhere and I can't find any information on it.

Here is an explanation of the isolation levels.

+4  A: 

You can just set the isolation level in a query before you run your statements. This assume that you do everything using the same session:

$mysqli = new mysqli('localhost', 'user', 'pass', 'db');
$mysqli->query("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE");
...

You may also want to turn off autocommit before hand since it changes the way serializable isolation works.

carson