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.
The error reported is:
PDOException: SQLSTATE[HY000]: General error: 1 no such function: Soundex
and the SQLite documentation says:
The soundex(X) function ... is omitted from SQLite by default
I've tried (from php docs) $db->sqliteCreateFunction('soundex', 'sqlite_soundex', 1);
where
function sqlite_soundex($string)
{
return soundex($string);
}
but get
...sqlite_soundex is not callable...
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
soundex()
function to php_pdo_sqlite.dllThe 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.
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");
}
}
Step 14: configure --disable-all --enable-cli --enable-pdo --with-pdo-sqlite=shared
Step 15: nmake php_pdo_sqlite.dll
The result was a php_pdo_sqlite.dll in the ...\Release_TS directory
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!
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.