Skip to content

Commit 278923e

Browse files
milodg
authored andcommitted
SQLiteStorage: fixed transaction execution
1 parent d2e2944 commit 278923e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Caching/Storages/SQLiteStorage.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class SQLiteStorage extends Nette\Object implements Nette\Caching\IStorage
2020
{
21-
/** @var PDO */
21+
/** @var \PDO */
2222
private $pdo;
2323

2424

@@ -29,7 +29,8 @@ public function __construct($path = ':memory:')
2929
$this->pdo->exec('
3030
PRAGMA foreign_keys = ON;
3131
CREATE TABLE IF NOT EXISTS cache (
32-
key BLOB NOT NULL PRIMARY KEY, data BLOB NOT NULL
32+
key BLOB NOT NULL PRIMARY KEY,
33+
data BLOB NOT NULL
3334
);
3435
CREATE TABLE IF NOT EXISTS tags (
3536
key BLOB NOT NULL REFERENCES cache ON DELETE CASCADE,
@@ -75,7 +76,7 @@ public function lock($key)
7576
*/
7677
public function write($key, $data, array $dependencies)
7778
{
78-
$this->pdo->prepare('BEGIN TRANSACTION');
79+
$this->pdo->exec('BEGIN TRANSACTION');
7980
$this->pdo->prepare('REPLACE INTO cache (key, data) VALUES (?, ?)')
8081
->execute(array($key, serialize($data)));
8182

@@ -87,7 +88,7 @@ public function write($key, $data, array $dependencies)
8788
$this->pdo->prepare('INSERT INTO tags (key, tag) SELECT ?, ?' . str_repeat('UNION SELECT ?, ?', count($arr) / 2 - 1))
8889
->execute($arr);
8990
}
90-
$this->pdo->prepare('COMMIT');
91+
$this->pdo->exec('COMMIT');
9192
}
9293

9394

0 commit comments

Comments
 (0)