tags:

views:

367

answers:

1

The SQLite3 Class has an option like this.

$db = new SQLite3('mysqlitedb.db', SQLITE3_OPEN_READONLY);

In PDO you would simply open with:

$db = new PDO('sqlite:mysqlitedb.db');

My question is however, is there a way to open a database with PDO, in READONLY mode?

+1  A: 

I don't think that's possible with pdo (yet?).
The pdo_sqlite driver of php 5.3 uses sqlite3_open() in pdo_sqlite_handle_factory() but you need sqlite3_open_v2() to pass the read only flag.

edit:
But a patch would be fairly easy. Take a look at pdo_mysql_handle_factory() in ext/pdo_mysql/mysql_driver.c and how it uses struct pdo_data_src_parser vars[] to parse the dns string.

VolkerK