如何在 php 中为 sqlite3 启用 PDO 驱动程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/929585/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 00:22:05  来源:igfitidea点击:

How to enable the PDO driver for sqlite3 in php?

phpsqlitepdoxampp

提问by Keira Nighly

My SQLite is version 3.4.0: image

我的 SQLite 是 3.4.0 版: 图像

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

但是我的 phpinfo 对 SQLitev3 的 PDO 支持没有启用/列出: 图像

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

我怎样才能启用它?我通过 XAMPP 安装了我的 Web 服务器。

采纳答案by Tom Haigh

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

我认为 sqlite3 的 PDO 驱动程序称为“sqlite”,因此您已经安装了它。sqlite2 驱动程序较旧。

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.

PDO_SQLITE 是一个驱动程序,它实现了 PHP 数据对象 (PDO) 接口以启用对 SQLite 3 数据库的访问。

在 PHP 5.1 中,SQLite 扩展还提供了 SQLite 2 数据库的驱动程序;虽然它在技术上不是 PDO_SQLITE 驱动程序的一部分,但它的行为类似,所以它与它一起记录。提供用于 PDO 的 SQLite 2 驱动程序主要是为了更轻松地将旧的 SQLite 2 数据库文件导入使用更快、更高效的 SQLite 3 驱动程序的应用程序。因此,SQLite 2 驱动程序的功能不如 SQLite 3 驱动程序丰富。

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

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

回答by Mladen Janjetovic

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

转到您的php.ini文件并搜索“sqlite”。这些评论大概是:

extension=php_pdo_sqlite.dll

extension=php_sqlite.dll

Uncomment them, and restart Apache.

取消注释,然后重新启动 Apache。

回答by Aram Hovhannisyan

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

"pdo_sqlite" 和 "sqlite3" 是不同的扩展名,并php.ini在不同的行中加载:

extension=php_pdo_sqlite.dll

extension=php_sqlite3.dll

回答by JLuc

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

我在 linux/unix 系统上修复了这个问题,在 php.ini 中添加了以下几行:

extension=pdo_sqlite.so
extension=sqlite.so