pdo sqlite 找不到驱动程序... php 文件未处理

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8803728/
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-26 05:32:29  来源:igfitidea点击:

pdo sqlite could not find driver... php file not processing

phpsqlitepdo

提问by acctman

Hi i'm received the could not find drivererror when trying to connect to sqlite via a php file. I've set permission to 777... PHP Version 5.2.16, i have the module install. any reason why its not finding the driver, also php.ini is showing the extension pdo.so and pdo_mysql.so installed.

嗨,我在尝试通过 php 文件连接到 sqlite 时收到了找不到驱动程序错误。我已将权限设置为 777... PHP 版本 5.2.16,我已安装模块。没有找到驱动程序的任何原因,php.ini 也显示安装了扩展 pdo.so 和 pdo_mysql.so。

PDO

PDO

PDO support enabled PDO drivers mysql

PDO 支持启用 PDO 驱动程序 mysql

pdo_mysql

pdo_mysql

PDO Driver for MySQL, client library version 5.0.92

MySQL 的 PDO 驱动程序,客户端库版本 5.0.92

try {
    // Connect to the SQLite Database.
    $db = new PDO('sqlite:.subscribers.db');
} catch(Exception $e) {
    die('connection_unsuccessful: ' . $e->getMessage());
}

采纳答案by devdRew

You need

你需要

[PDO_SQLITE]
extension=pdo_sqlite.so

to be enabled, for sqlite:.subscribers.db

启用,对于 sqlite:.subscribers.db

or, for windows:

或者,对于窗户:

[PHP_PDO_SQLITE]
extension=php_pdo_sqlite.dll

And ofcourse this extension in your extdirectory

当然还有你ext目录中的这个扩展

回答by Nino ?kopac

I had to actually install the extension, and this is how i did on Ubuntu 16running PHP 7.1:

我必须实际安装扩展程序,这就是我在运行PHP 7.1 的Ubuntu 16上所做的:

sudo apt install php7.1-sqlite3

sudo apt install php7.1-sqlite3

回答by JTC

On archlinux i had to do two things:

在 archlinux 上,我必须做两件事:

first install php-sqlite

首先安装php-sqlite

pacman -S php-sqlite

after that in my php.inifile for me in /etc/php/php.inii had to uncomment this line:

在那之后,在我的php.ini文件中,我/etc/php/php.ini不得不取消注释这一行:

;extension=pdo_sqlite.so

by removing semicolon.

通过删除分号。

Dont forget to restart server.

不要忘记重新启动服务器。

回答by dylan-myers

I am using a portable version of PHP on windows, using the inbuilt web server. I found the following steps helped:

我在 Windows 上使用便携式版本的 PHP,使用内置的 Web 服务器。我发现以下步骤有帮助:

  1. Renaming php.ini-development to php.ini
  2. Uncommenting extension_dir = "ext"under [PHP] (around line 700)
  3. making sure the following lines are in the php.ini:
  1. 将 php.ini-development 重命名为 php.ini
  2. extension_dir = "ext"在 [PHP] 下取消注释(大约第 700 行)
  3. 确保以下几行在 php.ini 中:
[sqlite3]    
sqlite3.extension_dir = "ext"    
extension = sqlite3    
extension = pdo_sqlite
  1. Running the php webserver with the following flag added on: - c C:\Path\to\PortablePHP\php.ini
  1. 运行添加了以下标志的 php 网络服务器: - c C:\Path\to\PortablePHP\php.ini

So currently my php command is php -S localhost:8081 -c B:\Downloads\php-7.2.6\php.ini.

所以目前我的 php 命令是php -S localhost:8081 -c B:\Downloads\php-7.2.6\php.ini.