Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update the SQLite version bundled with PHP

PHP 5.5 comes bundled with SQLite 3.7.7.1.

There have been ~ 20 newer releases of SQLite since then, and www.sqlite.org recommends to upgrade. In my case, I need a feature available only since SQLite 3.8.0.

As far as I understood, SQLite is not dynamically linked in PHP 5.5 but the sqlite source code is compiled into the built-in PHP PDO driver for SQLite.

Is there a way to use a current SQLite version in PHP without rebuilding PHP from source (e.g., somehow dynamically linking sqlite.dll)?

like image 708
Fabian Avatar asked Nov 01 '25 22:11

Fabian


1 Answers

I could produce a fresh php_pdo_sqlite.dll to drop into an existing PHP 5.5 Windows installation that includes the current version (3.8.1) of SQLite:

I followed the nice step-by-step guide to build PHP on Windows using Visual Studio 2012 Express (available from http://www.microsoft.com/en-us/download/details.aspx?id=34673).

In the PHP 5.5 sources, I have replaced the outdated sqlite amalgamation file ext\sqlite3\libsqlite\sqlite.c by the current one from http://www.sqlite.org/download.html.

I used configure --enable-pdo=shared --with-pdo-sqlite=shared.

This creates php_pdo_sqlite.dll that I could drop into an existing PHP 5.5 installation, replacing the previous (bundled) version of that file.

<?php
$dbh = new PDO('sqlite:test1.sqlite');
print_r("SQLite version " . $dbh->query('select sqlite_version()')->fetch()[0]);
$dbh = null;
?>

confirms:

SQLite version: 3.8.1
like image 197
Fabian Avatar answered Nov 03 '25 11:11

Fabian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!