File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 16
16
*/
17
17
class SQLiteJournal extends Nette \Object implements IJournal
18
18
{
19
+ /** @string */
20
+ private $ path ;
21
+
19
22
/** @var \PDO */
20
23
private $ pdo ;
21
24
@@ -28,8 +31,13 @@ public function __construct($path)
28
31
if (!extension_loaded ('pdo_sqlite ' )) {
29
32
throw new Nette \NotSupportedException ('SQLiteJournal requires PHP extension pdo_sqlite which is not loaded. ' );
30
33
}
34
+ $ this ->path = $ path ;
35
+ }
36
+
31
37
32
- $ this ->pdo = new \PDO ('sqlite: ' . $ path );
38
+ private function open ()
39
+ {
40
+ $ this ->pdo = new \PDO ('sqlite: ' . $ this ->path );
33
41
$ this ->pdo ->setAttribute (\PDO ::ATTR_ERRMODE , \PDO ::ERRMODE_EXCEPTION );
34
42
$ this ->pdo ->exec ('
35
43
PRAGMA foreign_keys = OFF;
@@ -58,6 +66,9 @@ public function __construct($path)
58
66
*/
59
67
public function write ($ key , array $ dependencies )
60
68
{
69
+ if (!$ this ->pdo ) {
70
+ $ this ->open ();
71
+ }
61
72
$ this ->pdo ->exec ('BEGIN ' );
62
73
63
74
if (!empty ($ dependencies [Cache::TAGS ])) {
@@ -89,6 +100,9 @@ public function write($key, array $dependencies)
89
100
*/
90
101
public function clean (array $ conditions )
91
102
{
103
+ if (!$ this ->pdo ) {
104
+ $ this ->open ();
105
+ }
92
106
if (!empty ($ conditions [Cache::ALL ])) {
93
107
$ this ->pdo ->exec ('
94
108
BEGIN;
You can’t perform that action at this time.
0 commit comments