V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
sbmzhcn
V2EX  ›  PHP

PHP 怎么支持 sqlite3,上网搜索不到答案才来问的

  •  
  •   sbmzhcn · 2015-01-05 13:52:51 +08:00 · 2706 次点击
    这是一个创建于 3402 天前的主题,其中的信息可能已经有所发展或是发生改变。
    sqlite3 -version
    3.8.7.4 2014-12-09 01:34:36 f66f7a17b78ba617acde90fc810107f34f1a1f2e


    php -v

    [root@li430-158 lnmp0.9]# php -v
    Zend Optimizer requires Zend Engine API version 220060519.
    The Zend Engine API version 220090626 which is installed, is newer.
    Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Optimizer.

    PHP Warning: PHP Startup: memcache: Unable to initialize module
    Module compiled with module API=20060613
    PHP compiled with module API=20090626
    These options need to match
    in Unknown on line 0
    PHP Warning: PHP Startup: pdo_mysql: Unable to initialize module
    Module compiled with module API=20060613
    PHP compiled with module API=20090626
    These options need to match
    in Unknown on line 0

    Deprecated: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0

    Deprecated: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
    PHP 5.3.7 (cli) (built: Jun 7 2013 07:52:07)
    Copyright (c) 1997-2011 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

    现在php就是不支持sqlite3,phpinfo里只有sqlite没有sqlite3,如果用 new SQLITE3创建数据库会提示不存在class sqlite3。 如何解决?

    在网上找了很多的问题没一个回答的,有的说php5.3已经默认支持,但为什么就是不行呢,有的是直接说sqlite3怎么安装的,sqlite3我已经安装了,但重要的是它怎么和php结合到一块去。
    7 条回复    2015-01-05 19:16:12 +08:00
    justinquan
        1
    justinquan  
       2015-01-05 13:58:46 +08:00
    你的版本是5.3.7 应该是支持的,直接打开php.ini(如果你的配置文件是其他名字请自行查找)
    在配置文件中找到的
    extension=php_pdo_sqlite.dll
    extension=php_sqlite3.dll

    将上述两行配置前面的";"字符删掉,然后保存后重启apache
    sbmzhcn
        2
    sbmzhcn  
    OP
       2015-01-05 14:05:11 +08:00
    这是 linux系统 。不是windows
    yyfearth
        4
    yyfearth  
       2015-01-05 14:13:39 +08:00
    @sbmzhcn 也是差不多的 到extension里面把相关的配置前面的";"字符删掉

    无非就不是dll而已
    shiny
        5
    shiny  
       2015-01-05 14:17:42 +08:00
    安装了 sqlite3,但是未必安装 php5-sqlite 😂
    cevincheung
        6
    cevincheung  
       2015-01-05 14:28:39 +08:00
    PHP默认已经内置了SQLITE(3)。
    new pdo('sqlite:/path') 默认就是SQLITE3的版本
    sbmzhcn
        7
    sbmzhcn  
    OP
       2015-01-05 19:16:12 +08:00
    最后用new pdo('sqlite:/path') 解决的。的确不支持new sqlite3但其它VPS上的就支持,extension 这地方怎么修改都不支持sqlite3.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1109 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:27 · PVG 02:27 · LAX 11:27 · JFK 14:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.