K
K
kolesnevg2012-02-08 15:26:31
PHP
kolesnevg, 2012-02-08 15:26:31

The level of isolation itself is changing !!! (php, pdo, mysql)?

Hello everyone,
I'm working with mysql using pdo, I'm trying to change the isolation level, but after the first request, it returns to the default value again. If anyone has come across please let me know.
//create connection
$x = new PDO("mysql:host=". db_host. ";dbname=". db_name, db_user, db_pass);
//change isolation level
$x->query("SET TRANSACTION ISOLATION LEVEL READ COMMITTED;");
//check it
$query = "SHOW VARIABLES LIKE '%tx_isolation%';";
$result = $x->query($query);
$res = $result->fetch(PDO::FETCH_ASSOC);
print_r($res);
//…
$x->query("select * from test");
// check again
$query = "SHOW VARIABLES LIKE '
$result = $x->query($query);
$res = $result->fetch(PDO::FETCH_ASSOC);
print_r($res);
as a result, we get two completely different values
​​Array
(
[Variable_name] => tx_isolation
[Value] => READ-COMMITTED
)
Array
(
[Variable_name] => tx_isolation
[Value] => REPEATABLE-READ
)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Beresnev, 2012-02-08
@sectus

Autocommit enabled?
dev.mysql.com/doc/refman/5.5/en/innodb-transaction-model.html

A
alexmuz, 2012-02-08
@alexmuz

Try like this: dev.mysql.com/doc/refman/5.0/en/set-transaction.html
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question