I am using latest OS X El Capitan. My MAMP is 3.5 PRO. I am running PHP 7.0.0 in it. You can see the info of the PHP here.
I figured that SQLite is available in OS X by default. But the version of this SQLite in OS X was 3.8. JSON1 extension is only available in SQLite since the version 3.9.
So first, I tried to upgrade this. I downloaded precompiled binaries (3.12.1) for OS X and replace the sqlite3
file in /etc/bin/
folder. I thought It was done because I check the console with running /usr/bin/sqlite3
directly. You can see the result below. The version is upgraded to the latest version.
Then I tried to check the SQLite version in PHP.
<blockquote>
<?php print_r(SQLite3::version()); ?>
</blockquote>
Unfortunately It said;
Array ( [versionString] => 3.8.10.2 [versionNumber] => 3008010 )
Then I stuck at this point. Where can I look next?
Update
I succesfully installed the SQLite 3.12.1 via homebrew.
brew install sqlite3 --with-json1 --with-ft5
And now I can run json functions in console. But still can't connect the API via PHP.
<?php
$db = new SQLite3("sqlite");
$sql = "create table user(name,phone);";
//$db->query("SELECT load_extension('myextension.so');");
$sql = 'insert into user (name, phone) values("oz", json(\'{"cell":"+491765", "home":"+498973"}\'));';
$db->exec($sql);
?>
Warning: SQLite3::exec(): no such function: json in /Users/Fehmi/Data/root/sqlite/info.php on line 17