功能测试:sqlite 不包含 soundex() [英] Functional test: sqlite does not include soundex()

查看:29
本文介绍了功能测试:sqlite 不包含 soundex()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试构建需要 soundex() 的功能测试失败,因为默认情况下该函数未在 pdo_sqlite 中编译.正在使用 LiipFunctionalTestBundle 构建功能测试.

Attempts to build a functional test where soundex() is required fail due to the fact that the function by default is not compiled in pdo_sqlite. Functional tests are being built using LiipFunctionalTestBundle.

报告的错误是:

PDOException: SQLSTATE[HY000]: 一般错误: 1 没有这样的功能:Soundex

PDOException: SQLSTATE[HY000]: General error: 1 no such function: Soundex

SQLite 文档说:

and the SQLite documentation says:

soundex(X) 函数 ... 默认情况下从 SQLite 中省略

The soundex(X) function ... is omitted from SQLite by default

我已经尝试过(来自 php 文档)$db->sqliteCreateFunction('soundex', 'sqlite_soundex', 1); where

I've tried (from php docs) $db->sqliteCreateFunction('soundex', 'sqlite_soundex', 1); where

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

但是得到

...sqlite_soundex 不可调用...

...sqlite_soundex is not callable...

那么,如何编译一个版本的Windows php_pdo_sqlite.dll?(SQLite 文档展示了如何编译普通"sqlite.dll.)或者有更好的解决方案吗?

So, how to compile a version of Windows php_pdo_sqlite.dll? (SQLite docs show how to compile a "plain" sqlite.dll.) Or is there a better solution?

>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

推荐答案

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

以下是对在 Windows 上构建您自己的 PHP 的说明的改编.我使用 Visual Studio 12 Express for Desktop &来自 windows.php.net 的 PHP 5.5 源代码.

How to add the soundex() function to php_pdo_sqlite.dll

The following is an adaptation of the instructions Build your own PHP on Windows. I used Visual Studio 12 Express for Desktop & PHP 5.5 source code from windows.php.net.

按照说明进行操作,直到将源代码提取到树中.此时我修改了 C:\php-sdk\phpdev\vc9\x86\php-5.5.18\ext\pdo_sqlite\config.w32,添加了 /D SQLITE_SOUNDEX

Proceed per instructions up to extracting source code into the tree. At that point I modified C:\php-sdk\phpdev\vc9\x86\php-5.5.18\ext\pdo_sqlite\config.w32, adding /D SQLITE_SOUNDEX

// $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

第十五步:nmake php_pdo_sqlite.dll

结果是 ...\Release_TS 目录中的一个 php_pdo_sqlite.dll

The result was a php_pdo_sqlite.dll in the ...\Release_TS directory

我需要将我的 PHP 安装从 5.4 更新到 5.5 并进行测试.原始的 sqlite dll 导致了 soundex() 错误.替换 dll 允许测试通过.成功!

I needed to update my PHP installation from 5.4 to 5.5 and tested. The original sqlite dll caused the soundex() error. The replacement dll allowed the test to pass. SUCCESS!

多次尝试失败后,将上面的第 14 步更改为 configure --disable-all --enable-pdo --with-pdo-sqlite=shared --enable-apache2-4handler 允许创建带有 soundex() 函数的 php_pdo_sqlite.dll.

After several failed attempts, changing Step 14 above to configure --disable-all --enable-pdo --with-pdo-sqlite=shared --enable-apache2-4handler allowed creation of a php_pdo_sqlite.dll with the soundex() function.

这篇关于功能测试:sqlite 不包含 soundex()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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