1--TEST--
2PDO_sqlite: Testing filename uri
3--EXTENSIONS--
4pdo_sqlite
5--FILE--
6<?php
7
8// create with in-memory database using shared cached
9$db = new PDO('sqlite:file::memory:?cache=shared');
10
11var_dump($db->exec('CREATE TABLE test_sqlite_filename_uri (id INT);'));
12
13// create second connection to in-memory database
14$db = new PDO('sqlite:file::memory:?cache=shared');
15
16var_dump($db->exec('SELECT * from test_sqlite_filename_uri'));
17
18// create with default read-write|create mode
19$filename = "file:" . __DIR__ . DIRECTORY_SEPARATOR . "pdo_sqlite_filename_uri.db";
20
21$db = new PDO('sqlite:' . $filename);
22
23var_dump($db->exec('CREATE TABLE test_sqlite_filename_uri (id INT);'));
24
25// create with readonly mode
26$filename = "file:" . __DIR__ . DIRECTORY_SEPARATOR . "pdo_sqlite_filename_uri.db?mode=ro";
27
28$db = new PDO('sqlite:' . $filename);
29
30var_dump($db->exec('CREATE TABLE test_sqlite_filename_uri_2 (id INT);'));
31
32?>
33--CLEAN--
34<?php
35$filename = __DIR__ . DIRECTORY_SEPARATOR . "pdo_sqlite_filename_uri.db";
36if (file_exists($filename)) {
37    unlink($filename);
38}
39?>
40--EXPECTF--
41int(0)
42int(0)
43int(0)
44
45Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in %s
46Stack trace:
47%s
48#1 {main}
49  thrown in %s
50