On my Ubuntu 15.04 machine I'm trying to load an sqlite-extension within my php code using the following snippet:
<?php #content of test.php
$db = new SQLite3(':memory:');
$db->query("SELECT load_extension('/dir/to/sqlite/extension/libsqlitefunctions.so');");
$resultSet = $db->query("SELECT asin(1) as a;");
But I always get the following error message:
PHP Warning: SQLite3::query(): not authorized in /my/dir/test.php on line 3
PHP Stack trace:
PHP 1. {main}() /my/dir/test.php:0
PHP 2. SQLite3->query() /my/dir/test.php:3
PHP Warning: SQLite3::query(): Unable to prepare statement: 1, no such function: asin in /my/dir/test.php on line 4
PHP Stack trace:
PHP 1. {main}() /my/dir/test.php:0
PHP 2. SQLite3->query() /my/dir/test.php:4
Loading the same extension from the command line works fine:
$sqlite3
SQLite version 3.8.7.4 2014-12-09 01:34:36
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> SELECT load_extension('/dir/to/sqlite/extension/libsqlitefunctions.so');
sqlite> SELECT ASIN(1) as a;
1.5707963267949
See this question on how to get this to work.
Can anyone help me get this working from within php on Ubuntu 15.04.
Thanx a lot in advance.
Cheers, D.
PS: as I use this when running phpunit tests with sqlite as database, I run it on the command line and not in a web-server context.