File tree 3 files changed +86
-1
lines changed
3 files changed +86
-1
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,16 @@ pdo_sqlite
5
5
--FILE--
6
6
<?php
7
7
8
- // create with in-memory database
8
+ // create with in-memory database using shared cached
9
9
$ db = new PDO ('sqlite:file::memory:?cache=shared ' );
10
10
11
11
var_dump ($ db ->exec ('CREATE TABLE test1 (id INT); ' ));
12
12
13
+ // create second connection to in-memory database
14
+ $ db = new PDO ('sqlite:file::memory:?cache=shared ' );
15
+
16
+ var_dump ($ db ->exec ('SELECT * from test1 ' ));
17
+
13
18
// create with default read-write|create mode
14
19
$ filename = "file: " . __DIR__ . DIRECTORY_SEPARATOR . "pdo_sqlite_filename_uri.db " ;
15
20
@@ -35,6 +40,7 @@ if (file_exists($filename)) {
35
40
--EXPECTF--
36
41
int(0)
37
42
int(0)
43
+ int(0)
38
44
39
45
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in %s
40
46
Stack trace:
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ PDO_sqlite: Testing filenames with open_basedir
3
+ --EXTENSIONS--
4
+ pdo_sqlite
5
+ --INI--
6
+ open_basedir={TMP}
7
+ --FILE--
8
+ <?php
9
+
10
+ // create in basedir
11
+ $ filename = sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ;
12
+
13
+ $ db = new PDO ('sqlite: ' . $ filename );
14
+
15
+ var_dump ($ db ->exec ('CREATE TABLE test1 (id INT); ' ));
16
+
17
+ // create outside basedir
18
+ $ filename = __DIR__ . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ;
19
+
20
+ new PDO ('sqlite: ' . $ filename );
21
+ ?>
22
+
23
+ --CLEAN--
24
+ <?php
25
+ $ filenames = [
26
+ sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ,
27
+ __DIR__ . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ,
28
+ ];
29
+ foreach ($ filenames as $ filename ) {
30
+ if (file_exists ($ filename )) {
31
+ unlink ($ filename );
32
+ }
33
+ }
34
+ ?>
35
+ --EXPECTF--
36
+ int(0)
37
+
38
+ Fatal error: Uncaught PDOException: PDO::__construct(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s:%d
39
+ Stack trace:
40
+ %s
41
+ #1 {main}
42
+
43
+ Next PDOException: open_basedir prohibits opening %s in %s:%d
44
+ Stack trace:
45
+ %s
46
+ #1 {main}
47
+ thrown in %s
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ PDO_sqlite: Testing URIs with open_basedir
3
+ --EXTENSIONS--
4
+ pdo_sqlite
5
+ --INI--
6
+ open_basedir={TMP}
7
+ --FILE--
8
+ <?php
9
+
10
+ // create in basedir
11
+ $ filename = sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ;
12
+
13
+ new PDO ('sqlite:file: ' . $ filename );
14
+ ?>
15
+
16
+ --CLEAN--
17
+ <?php
18
+ $ filenames = [
19
+ sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ,
20
+ ];
21
+ foreach ($ filenames as $ filename ) {
22
+ if (file_exists ($ filename )) {
23
+ unlink ($ filename );
24
+ }
25
+ }
26
+ ?>
27
+ --EXPECTF--
28
+ Fatal error: Uncaught PDOException: open_basedir prohibits opening %s in %s:%d
29
+ Stack trace:
30
+ %s
31
+ #1 {main}
32
+ thrown in %s
You can’t perform that action at this time.
0 commit comments