I want to provide a setup feature in my next project and I'm wondering if it's possible to create a SQLite 3 database from scratch with PDO or I'm just stuck at connecting to existing databases via DSN?
我想在我的下一个项目中提供一个设置功能,我想知道是否可以从头开始用PDO创建一个SQLite 3数据库,或者我只是坚持通过DSN连接到现有数据库?
If it isn't possible with PDO is there any way to create a new DB via PHP?
如果PDO无法通过PHP创建新数据库有什么办法吗?
1 个解决方案
#1
22
A new sqlite database is created when you open a connection to one that doesn't exist. You can just check if the file exists, and then if it doesn't, then just create a new database connection and insert the tables.
打开与不存在的连接时创建的新sqlite数据库。您可以检查文件是否存在,如果不存在,则只需创建一个新的数据库连接并插入表。
#1
22
A new sqlite database is created when you open a connection to one that doesn't exist. You can just check if the file exists, and then if it doesn't, then just create a new database connection and insert the tables.
打开与不存在的连接时创建的新sqlite数据库。您可以检查文件是否存在,如果不存在,则只需创建一个新的数据库连接并插入表。