How to enable the PDO driver for sqlite3 in php?

十年热恋 提交于 2019-12-01 15:47:22

问题


My SQLite is version 3.4.0: image

However my phpinfo's PDO support for SQLitev3 is not enabled/listed: image

How can I enable it? I installed my web server via XAMPP.


回答1:


I think that the PDO driver for sqlite3 is called 'sqlite', so you already have it installed. The sqlite2 driver is older.

PDO_SQLITE is a driver that implements the PHP Data Objects (PDO) interface to enable access to SQLite 3 databases.

In PHP 5.1, the SQLite extension also provides a driver for SQLite 2 databases; while it is not technically a part of the PDO_SQLITE driver, it behaves similarly, so it is documented alongside it. The SQLite 2 driver for PDO is provided primarily to make it easier to import legacy SQLite 2 database files into an application that uses the faster, more efficient SQLite 3 driver. As a result, the SQLite 2 driver is not as feature-rich as the SQLite 3 driver.

From http://php.net/manual/en/ref.pdo-sqlite.php




回答2:


Go to your php.ini file and search for "sqlite". These are probably commented:

extension=php_pdo_sqlite.dll

extension=php_sqlite.dll

Uncomment them, and restart Apache.




回答3:


edit: there is a discussion on the topic here:

http://www.apachefriends.org/f/viewtopic.php?f=16&t=34389&sid=c99e3edebef9f297aff3f2f179c50ccc&p=141255




回答4:


"pdo_sqlite" and "sqlite3" are different extensions and are loaded in php.ini in different lines:

extension=php_pdo_sqlite.dll

extension=php_sqlite3.dll



回答5:


I fixed this issue on a linux/unix system with the following lines added in php.ini :

extension=pdo_sqlite.so
extension=sqlite.so


来源:https://stackoverflow.com/questions/929585/how-to-enable-the-pdo-driver-for-sqlite3-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!