Reputation: 31
I'm populating a temporary table with items, and then use this table to filter with a SQL JOIN operator, but it does not work.
Snippet below show the problem.
$pdo->beginTransaction();
$pdo->->exec("INSERT INTO LISTEREF2 (DATA) VALUES ('foo1');");
$sth = $pdo->query('SELECT r.* FROM LISTEREF2 r');
if ($sth) {
$rowTable = $sth->fetchAll();
logIt('fetchAll '.print_r($rowTable,true));
}
Populating is OK (rowCount=1), but the 'select' on this table is empty as if the connection is different.
Upvotes: 2
Views: 41
Reputation: 31
I have found a solution to my problem.
By replacing:
$pdo->beginTransaction();
with:
$pdo->setAttribute(\PDO::ATTR_AUTOCOMMIT, false);
$pdo->exec("SET TRANSACTION READ ONLY ISOLATION LEVEL READ COMMITTED NO WAIT");
Upvotes: 1