phpapachesqlitexampp

Cannot loadExtension in SQLite3 module, PHP


I need to use extension example.dll with SQLite3 object in PHP. Extension has non-standard entry point custom_init. sqlite3.extension_dir in php.ini is specified properly. Tried the following code:

$dbconn = new SQLite3('test.db');
$dbconn->loadExtension('example.dll');
$dbconn->exec("SELECT load_extension('example.dll');");

As one can see, I used two approches to load it.

First approach: $dbconn->loadExtension('sqldba.dll');.

Second approach: $dbconn->exec("SELECT load_extension('example.dll', 'custom_init');");.

Upd: somehow related: How to load sqlite extension in PDO?


Solution

  • This won't work on IIS anyway, which is (apperently) preferable for me. According to this (line 414) it is only enabled in ZTS(Zend Thread Safety). Disabling it is discussed here. Still no idea what's wrong with Apache config.

    Nnnope. Maybe someone should add a "custom entry point" feature request to PHP tracker, it doesn't seem that difficult.

    You have to call sqlite3_enable_load_extension before doing load_extension from query, and there is no analogue of sqlite3_enable_load_extension in php-sqlite. Patching PDO-Sqlite for this is described here, but it's very unsafe. Adding this as new feature in php-sqlite would be much better.