File tree 3 files changed +82
-1
lines changed
3 files changed +82
-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
+ new PDO ('sqlite: ' . $ filename );
14
+
15
+ // create outside basedir
16
+ $ filename = __DIR__ . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ;
17
+
18
+ new PDO ('sqlite: ' . $ filename );
19
+ ?>
20
+
21
+ --CLEAN--
22
+ <?php
23
+ $ filenames = [
24
+ sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ,
25
+ __DIR__ . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ,
26
+ ];
27
+ foreach ($ filenames as $ filename ) {
28
+ if (file_exists ($ filename )) {
29
+ unlink ($ filename );
30
+ }
31
+ }
32
+ ?>
33
+ --EXPECTF--
34
+ Fatal error: Uncaught PDOException: PDO::__construct(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s:%d
35
+ Stack trace:
36
+ %s
37
+ #1 {main}
38
+
39
+ Next PDOException: open_basedir prohibits opening %s in %s:%d
40
+ Stack trace:
41
+ %s
42
+ #1 {main}
43
+ 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