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