本文介绍了使用PDO以READONLY形式打开SQLite3吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SQLite3类具有这样的选项.
The SQLite3 Class has an option like this.
$db = new SQLite3('mysqlitedb.db', SQLITE3_OPEN_READONLY);
在PDO中,您只需打开:
In PDO you would simply open with:
$db = new PDO('sqlite:mysqlitedb.db');
但是我的问题是,有没有办法在READONLY模式下用PDO打开数据库?
My question is however, is there a way to open a database with PDO, in READONLY mode?
推荐答案
随着PHP 7.3的发布(预计于2018年底发布),这将成为可能.
This will become possible with the release of PHP 7.3 (estimated for release in late 2018).
其语法如下:
$db = new PDO('sqlite:mysqlitedb.db', null, null, [PDO::SQLITE_ATTR_OPEN_FLAGS => PDO::SQLITE_OPEN_READONLY]);
这篇关于使用PDO以READONLY形式打开SQLite3吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!