简体   繁体   English

如何在 Apache 2.4 (Windows 7) 上为 PHP 5.6.14 配置 SQLite3?

[英]How to configure SQLite3 for PHP 5.6.14 on Apache 2.4 (Windows 7)?

I'm on Windows 7, using PHP Version 5.6.14 on Apache 2.4 and I'm trying to access to a SQLite3 database.我在 Windows 7 上,在 Apache 2.4 上使用 PHP 版本 5.6.14,我正在尝试访问 SQLite3 数据库。

I'm obtaining ....我正在获取....

Fatal error : Class 'SQLite3' not found致命错误:找不到“SQLite3”类

Here you're a simple php code ...这是一个简单的php代码......

<?php
  $db = new SQLite3('phpdb');

  if ($db) {
    $db->query("CREATE TABLE dogbreeds (Name VARCHAR(255), MaxAge INT);");
    $db->query("INSERT INTO dogbreeds VALUES ('Doberman', 15)");
    $result = $db->query("SELECT Name FROM dogbreeds");
    var_dump($result->fetchArray(SQLITE3_ASSOC));
  } else {
    print "Connection to database failed!\n";
  }
?>

I've just looking for information about and based on this at the moment I've this configuration in my php.ini file ...我只是在寻找有关并基于此的信息,目前我的 php.ini 文件中有此配置...

extension=php_pdo_sqlite.dll
extension=php_sqlite3.dll
sqlite3.extension_dir = "D:\Cesare\Lavoro\Utili\Php\5-6-14\ext"

Any suggestions?有什么建议? Thank you very much in advance ....非常感谢您提前......

Cesare切萨雷

Enable extension php by removing the ";"通过删除“;”启用扩展php in front of ";extension=php_sqlite3.dll" in php.ini.在 php.ini 中的“;extension=php_sqlite3.dll”前面。 Can you also manually check if the extensions are there in the path?您还可以手动检查路径中是否存在扩展名吗?

`extension=php_pdo_sqlite.dll` AND `extension=php_sqlite3.dll`. 

Try this尝试这个

$db = sqlite_open("/absolute/path/my_sqlite.db");

or或者

 $db = new SQLiteDatabase('filename')) 

http://php.net/manual/en/book.sqlite.php http://php.net/manual/en/book.sqlite.php

I met the same problem, I solved it by changing the "extension_dir" using the absolute path我遇到了同样的问题,我通过使用绝对路径更改“extension_dir”来解决它

extension_dir = "C:/php/php7.0/ext"

the others setting其他设置

extension=php_pdo_sqlite.dll
extension=php_sqlite3.dll
sqlite3.extension_dir = "C:/php/php7.0/ext"

I ran into the same problem: -I am doing the LinkedIn Learning for SQL Essentials.我遇到了同样的问题:-我正在为 SQL Essentials 进行 LinkedIn 学习。

-My OS is windows server 2012 r2 -我的操作系统是 windows server 2012 r2

-I downloaded xampp from this website https://bw.org/ldcsql/ , given by the instructor. - 我从这个网站https://bw.org/ldcsql/下载了 xampp,由讲师提供。 I specifically downloaded the xampp version on this website even though there is a newer one(I uninstalled the newer one and installed the one from the website).我特地在这个网站上下载了 xampp 版本,即使有更新的版本(我卸载了较新的版本并从网站安装了一个)。

-Installed sqlite from https://www.sqlite.org/download.html (downloaded sqlite-dll-win64-x64-3240000.zip for my computer and the "sqlite-tools-win32-86-3240000.zip"). - 从https://www.sqlite.org/download.html安装 sqlite(为我的电脑下载了 sqlite-dll-win64-x64-3240000.zip 和“sqlite-tools-win32-86-3240000.zip”)。 I unzipped them and copied the DLL and the def(from dll 64) to system32 folder and the "sqlite3" Application (from sqlite-tools) to system32 as well.我解压缩它们并将 DLL 和 def(从 dll 64)复制到 system32 文件夹,并将“sqlite3”应用程序(从 sqlite-tools)复制到 system32。 A reference website just in case https://mislav.net/rails/install-sqlite3/一个参考网站,以防万一https://mislav.net/rails/install-sqlite3/

Note: when I say "install" it means that I pasted the files to the system32, there is no wizard installation or anything else.注意:当我说“安装”时,这意味着我将文件粘贴到 system32,没有安装向导或其他任何东西。

-In C:\\xampp\\php I looked for the php.ini which is of type "Configuration Settings", is NOT the php.ini-production NOR the php.ini-development. -在 C:\\xampp\\php 中,我查找了“配置设置”类型的 php.ini,它不是 php.ini-production 也不是 php.ini-development。 Inside there these should be uncommented: extension=pdo_mysql, extension=pdo_sqlite and extension=sqlite3.在里面这些应该是未注释的:extension=pdo_mysql、extension=pdo_sqlite 和 extension=sqlite3。

-Also in C:\\xampp\\php\\ext check that you have php_pdo_mysql.dll, php_pdo_sqlite.dll and php_pdo_sqlite3.dll -还在 C:\\xampp\\php\\ext 中检查您是否有 php_pdo_mysql.dll、php_pdo_sqlite.dll 和 php_pdo_sqlite3.dll

And after all that it worked毕竟它奏效了

如果您使用 XAMPP,请单击“配置”按钮选择 PHP(php.ini) 然后搜索“sqlite3”取消注释 ;extension=sqlite3 像这样,extension=sqlite3 然后找到 [sqlite3] 并写下您的 php 文件和 sqlite 的路径数据库位于 [sqlite3] sqlite3.extension_dir ="D:\\xampp\\htdocs" 然后在浏览器中输入 localhost/yourphpfile.php 你会看到查询的结果。

System xuname: Void 4.19.118_1 armv7l Unknown uptodate rF package: php-7.4.5_1, php-sqlite-7.4.5_1 Actual behavior I'm trying to get the PHP SQLite3 extension to work on my Raspberry PI.系统 xuname:Void 4.19.118_1 armv7l 未知最新 rF 包:php-7.4.5_1、php-sqlite-7.4.5_1 实际行为 我试图让 PHP SQLite3 扩展在我的 Raspberry PI 上工作。 I installed the above packages and enabled the extension in /etc/php/php.ini by uncommenting ;extension=sqlite3.我安装了上述软件包并通过取消注释 ;extension=sqlite3 启用了 /etc/php/php.ini 中的扩展。

Executing php -m does not list sqlite as a PHP module.执行 php -m 不会将 sqlite 列为 PHP 模块。 Executing php -i does not mention any SQLite3 support.执行 php -i 没有提到任何 SQLite3 支持。

Expected behavior SQLite3 should work after installing php-sqlite-7.4.5_1 and enabling the extension in /etc/php/php.ini.预期行为 SQLite3 在安装 php-sqlite-7.4.5_1 并在 /etc/php/php.ini 中启用扩展后应该可以工作。

Steps to reproduce the behavior Install the above packages, enable SQLite3 extension and run php -r 'new SQLite3("db");':重现行为的步骤安装上述软件包,启用 SQLite3 扩展并运行 php -r 'new SQLite3("db");':

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM