ryandesign at macports.org
Thu Jan 29 13:31:41 PST 2009
On Jan 28, 2009, at 22:58, M. Brooks Clark wrote:
> Are there any tricks to getting sqlite3 support with php? I've
> installed php5 +sqlite and php5-sqlite3, but when I try to access a
> page, I get the following error:
> Fatal error: Call to undefined function sqlite3_open() in /Users...
> phpinfo() gives me the following:
> SQLite supportenabled
> PECL Module version2.0-dev $Id: sqlite.c,v 220.127.116.11.2.11
> 2008/12/01 12:28:27 felipe Exp $
> SQLite Library2.8.17
> SQLite EncodingUTF-8
> DirectiveLocal ValueMaster Value
> SQLite3 supportenabled
> SQLite3 module version0.6
> SQLite Library3.5.9
> I'm at a loss. Any suggestions would be appreciated.
Ok, I don't use SQLite in PHP or elsewhere, but I just spent a lot of
time researching the available SQLite interfaces in PHP, so pardon me
if some of the below is already self-explanatory to you; it wasn't to
me and I want to write it out to make sure I got it right.
PHP offers two built-in interfaces for accessing SQLite databases: a
procedural API and an object-oriented interface using PDO (PHP Data
Objects). If you install the php5 port with the +sqlite3 variant, you
get both of them. The procedural API is documented here and includes
such functions as sqlite_open():
The PDO interface is documented here and involves you using a PDO
The catch is that the procedural API is only for SQLite 2 databases.
The only built-in interface for using SQLite 3 databases is via PDO.
There is also a PECL extension, php-sqlite3, which was developed
during 2008, currently at version 0.6. This is what the php5-sqlite3
port installs. But it does not provide the sqlite3_open function you
are seeking. Rather, it gives you an object-oriented interface based
around three classes: SQLite3, SQLite3Stmt and SQLite3Result. It is
described here, rather incompletely, notably the installation
instructions are totally missing:
There is also the PECL page about the extension, but it doesn't have
any documentation at all:
As far as I can tell, to use it, you add the line "extension =
sqlite3.so" to your php.ini.
I finally found the sqlite3_open function you're trying to use in
another extension which is also called php-sqlite3. This one was
developed from 2005 to 2007 and is currently at version 0.5:
We don't have a MacPorts port for this extension.
So after all that, if this is a web app you are making, then I
suggest you use the built-in PDO SQLite3 interface since it is well-
supported and doesn't require installing an extension. If this is
someone else's web app and you're not in a position to rewrite it to
use PDO SQLite3 and you can't convince its developer to do so, then
you'll have to either write a port for this earlier php-sqlite3
extension (though I'm not sure what we would call the port) or
install it manually.
More information about the macports-users