PHP无法与SQLite一起使用 [英] PHP isn't working with SQLite

查看:107
本文介绍了PHP无法与SQLite一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这是我要设置的第一台服务器.我有一个运行Ubuntu 11.10的系统.我正在运行Lighttpd并设置了PHP,但是我希望PHP和SQLite可以一起工作.我使用以下方法安装了它们:

Okay, so this is my first server I'm setting up. I have a system running Ubuntu 11.10. I'm running Lighttpd and have PHP set up, but I want PHP and SQLite to work together. I installed them using:

sudo apt-get install lighttpd
sudo apt-get install php5-cgi
sudo apt-get install sqlite
sudo apt-get install php5-sqlite

PHP可以正常工作,但是其中包含sqlite命令的任何脚本只会返回空白页面.我打开了php错误消息并运行了该脚本:

PHP works fine, but any script with a sqlite command in it just returns a blank page. I turned on php error messages and ran this script:

<?php
echo sqlite_libversion();
echo "<br>";
echo phpversion();
?>

哪个返回:

Fatal error: Call to undefined function sqlite_libversion()

出了什么问题? :(

php -m产生此:

[PHP模块] bcmath bz2日历核心ctype日期dba dom ereg exif fileinfo过滤器ftp gettext哈希iconv json libxml mbstring mhash openssl pcntl pcre PDO pdo_sqlite Phar posix readline反射 会话shmop SimpleXML soap套接字SPL sqlite3标准sysvmsg sysvsem sysvshm标记生成器wddx xml xmlreader xmlwriter zip zlib

[PHP Modules] bcmath bz2 calendar Core ctype date dba dom ereg exif fileinfo filter ftp gettext hash iconv json libxml mbstring mhash openssl pcntl pcre PDO pdo_sqlite Phar posix readline Reflection session shmop SimpleXML soap sockets SPL sqlite3 standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter zip zlib

推荐答案

根据 http://packages.ubuntu.com/oneiric/all/php5-sqlite/filelist php5-sqlite包含两个扩展模块

According to http://packages.ubuntu.com/oneiric/all/php5-sqlite/filelist the php5-sqlite contains two extension modules

  • pdo_sqlite.so -> http://docs.php.net/pdo
  • sqlite3.so -> http://docs.php.net/sqlite3

所以php5-sqlite似乎没有提供您要查找的模块.
如果您没有大量的旧代码,我建议您使用 PDO ,尤其是.因为sqlite模块将从核心php移到pecl ( pecl没什么问题...):

so it looks like php5-sqlite doesn't provide the module you're looking for.
If you don't have tons of legacy code I rather suggest you use PDO, esp. since the sqlite module is going to be moved from core php to pecl (nothing wrong with pecl though...):

自PHP 5.0起,此扩展与PHP捆绑在一起.从PHP 5.4开始,此扩展只能通过PECL使用.
Since PHP 5.0 this extension was bundled with PHP. Beginning with PHP 5.4, this extension is available only via PECL.

这篇关于PHP无法与SQLite一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆