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 1616 */
1717class SQLiteJournal extends Nette \Object implements IJournal
1818{
19+ /** @string */
20+ private $ path ;
21+
1922 /** @var \PDO */
2023 private $ pdo ;
2124
@@ -28,8 +31,13 @@ public function __construct($path = ':memory:')
2831 if (!extension_loaded ('pdo_sqlite ' )) {
2932 throw new Nette \NotSupportedException ('SQLiteJournal requires PHP extension pdo_sqlite which is not loaded. ' );
3033 }
34+ $ this ->path = $ path ;
35+ }
36+
3137
32- $ this ->pdo = new \PDO ('sqlite: ' . $ path );
38+ private function open ()
39+ {
40+ $ this ->pdo = new \PDO ('sqlite: ' . $ this ->path );
3341 $ this ->pdo ->setAttribute (\PDO ::ATTR_ERRMODE , \PDO ::ERRMODE_EXCEPTION );
3442 $ this ->pdo ->exec ('
3543 PRAGMA foreign_keys = OFF;
@@ -58,6 +66,9 @@ public function __construct($path = ':memory:')
5866 */
5967 public function write ($ key , array $ dependencies )
6068 {
69+ if (!$ this ->pdo ) {
70+ $ this ->open ();
71+ }
6172 $ this ->pdo ->exec ('BEGIN ' );
6273
6374 if (!empty ($ dependencies [Cache::TAGS ])) {
@@ -89,6 +100,9 @@ public function write($key, array $dependencies)
89100 */
90101 public function clean (array $ conditions )
91102 {
103+ if (!$ this ->pdo ) {
104+ $ this ->open ();
105+ }
92106 if (!empty ($ conditions [Cache::ALL ])) {
93107 $ this ->pdo ->exec ('
94108 BEGIN;
You can’t perform that action at this time.
0 commit comments