-->

功能测试:SQLite不包括同音()(Functional test: sqlite does no

2019-10-21 06:43发布

试图建立一个功能测试,其中SOUNDEX()是必需的失败,由于在默认情况下该功能在PDO_SQLITE未编译。 功能测试正在使用LiipFunctionalTestBundle建造。

报告的错误是:

PDOException:SQLSTATE [HY000]:常规错误:1没有这样的功能:探测法

和SQLite的文档说:

的SOUNDEX(X)功能......从SQLite的默认省略

我试过(从PHP文档) $db->sqliteCreateFunction('soundex', 'sqlite_soundex', 1); 哪里

    function sqlite_soundex($string)
    {
        return soundex($string);
    }

但得到

... sqlite_soundex是不可调用的...

那么,如何编译一个版本的Windows php_pdo_sqlite.dll ? (SQLite的文档显示如何编译一个“普通” sqlite.dll)。或者是有没有更好的解决办法?

编辑 - 与MS的Visual Studio 12 Express中,编译时间选项未知!

>cl sqlite3.c  -SQLITE_SOUNDEX  -link -dll -out:php_pdo_sqlite.dll
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.50727.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9002 : ignoring unknown option '-SQLITE_SOUNDEX'
sqlite3.c
Microsoft (R) Incremental Linker Version 11.00.50727.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:sqlite3.exe
-dll
-out:php_pdo_sqlite.dll
sqlite3.obj

Answer 1:

如何添加soundex()函数来php_pdo_sqlite.dll

以下是说明适应Windows上构建自己的PHP 。 我使用的Visual Studio 12 Express,用于从windows.php.net台式机和PHP 5.5的源代码。

根据说明进行长达提取源代码转换成树。 在这一点上我修改C:\php-sdk\phpdev\vc9\x86\php-5.5.18\ext\pdo_sqlite\config.w32 ,加入/D SQLITE_SOUNDEX

config.w32 snippet
// $Id$
// vim:ft=javascript

ARG_WITH("pdo-sqlite", "for pdo_sqlite support", "no");

if (PHP_PDO_SQLITE != "no") {
    EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c", null, "/DSQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 /D SQLITE_SOUNDEX /I" + configure_module_dirname + "/../sqlite3/libsqlite /I" + configure_module_dirname);

    ADD_EXTENSION_DEP('pdo_sqlite', 'pdo');
    // If pdo_sqlite is static, and sqlite3 is also static, then we don't add a second copy of the sqlite3 libs
    if (PHP_PDO_SQLITE_SHARED || PHP_SQLITE3_SHARED || PHP_SQLITE3 == 'no') {
        ADD_SOURCES(configure_module_dirname + "/../sqlite3/libsqlite", "sqlite3.c", "pdo_sqlite");
    }
}

步骤14: configure --disable-all --enable-cli --enable-pdo --with-pdo-sqlite=shared

步骤15: nmake php_pdo_sqlite.dll

其结果是在... \ Release_TS目录php_pdo_sqlite.dll

我需要更新我的PHP安装从5.4到5.5,并进行测试。 原来的sqlite的DLL造成的同音()错误。 替换DLL允许测试通过。 成功!

编辑 - 为PHP 7.0.0

多次失败的尝试后,改变上述步骤14至configure --disable-all --enable-pdo --with-pdo-sqlite=shared --enable-apache2-4handler允许一个的创建php_pdo_sqlite.dllsoundex()函数。



文章来源: Functional test: sqlite does not include soundex()