在需要soundex()的情况下,尝试构建函数测试失败,因为默认情况下该函数没有在pdo_sqlite中编译。正在使用LiipFunctionalTestBundle构建功能测试。
报告的错误是:
PDOException: SQLSTATEHY000:一般错误:1没有这样的函数: Soundex
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。)还是有更好的解决方案?
编辑-使用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发布于 2014-11-16 14:55:14
如何将soundex()函数添加到php_pdo_sqlite.dll
下面是对指令在Windows上构建自己的PHP的改编。我使用了VisualStudio12Express for Desktop &PHP5.5来自windows.php.net的源代码。
按照指令进行,直到将源代码提取到树中。这时,我修改了C:\php-sdk\phpdev\vc9\x86\php-5.5.18\ext\pdo_sqlite\config.w32,添加了/D SQLITE_SOUNDEX
config.w32片段
// $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
结果是php_pdo_sqlite.dll目录中的...\Release_TS
我需要将PHP安装从5.4更新到5.5并进行测试。原始sqlite导致soundex()错误。替换dll允许测试通过。成功!
编辑-用于PHP 7.0.0
在几次尝试失败后,将上面的步骤14更改为configure --disable-all --enable-pdo --with-pdo-sqlite=shared --enable-apache2-4handler允许使用soundex()函数创建一个php_pdo_sqlite.dll。
https://stackoverflow.com/questions/26877299
复制相似问题