views:

343

answers:

10

I'm running MicroApache (http://microapache.amadis.sytes.net) on Windows XP and would like to use SQLite 3 databases.

The PHP version is 5.2.9-2.

My MicroApache version has SQLite 2 support through 2 lines in the php.ini:
extension=php_pdo.dll
extension=php_sqlite.dll

I test whether the extension works in 3 ways:
1. phpinfo()
2. extension_loaded() and get_loaded_extensions()
3. using sample code that var_dump()s the constant SQLITE3_NUM (should be the integer 2) and tries to create a database (error: class 'SQLite3' does not exist)

Things I have tried (if I can remember them all):
1. copied php_sqlite3.dll from a full installation of PHP and added "extension=php_sqlite3.dll" to php.ini
-> error "Procedure entry point gc_remove_zval_from_buffer was not found in php5ts.dll"
2. compressed the DLL with UPX (like the other DLLs of MicroApache seem to be)
-> does not display an error on start, nor in the log file, but does not work
3. tried various things with php.ini
- created a section "[sqlite3]"
- prefixed "sqlite3." to "extension_dir=." and "extension=php_sqlite3.dll"
- ...
4. tried to use PDO, it says it 'could not find driver'

Who can help me get SQLite 3 to work?

A: 

Sounds more like a problem with the test code. Have you cross-checked by running on an SQLite system with standard Apache and the same version of PHP? What are the result from phpinfo() etc?

The recent MicroApache distros come with a PHP/SQLite guestbook as a demo/test. Does this not work?

Come to think of it you may not have spotted that there's an SQLite distro. Why not revisit the site and check the other versions out (just unzip and run) ...

The site will only let me post one link at a time so here goes 1 of 4...

MicroApache 2.0.63+PHP 4.4.9+SQLite: http://microapache.amadis.sytes.net/bin/MicroApache-2.0.63-PHP-4.4.9-SQLite.zip

As always I point out that MicroApache isn't intended to be used on a public-facing webserver without paying specific attention to the security config. It was developed merely as a way of sharing information locally via floppy or USB stick. It's easy enough to harden though.

Mad Max
A: 

Link 2 of 4:

MicroApache 2.0.63+PHP 5.2.9+SQLite: http://microapache.amadis.sytes.net/bin/MicroApache-2.0.63-PHP-5.2.9-SQLite.zip

Mad Max
A: 

Link 3 of 4:

MicroApache 1.3.41+PHP 4.4.9+SQLite: http://microapache.amadis.sytes.net/bin/MicroApache-1.3.41-PHP-4.4.9-SQLite.zip

Mad Max
A: 

Link 4 of 4: I hope you find these useful. There's a tiny guestbook demo which demonstrates that PHP and SQlite work properly.

MicroApache 1.3.41+PHP 4.4.9+SQLite+GD2: http://microapache.amadis.sytes.net/bin/MicroApache-1.3.41-PHP-4.4.9-SQLite-GD2.zip

Had lots of problems submitting posts as I'm a new user here and there are quite a few restrictions (and pages don't always load and seem to frequently error) - Hopefully you can play with these distros and solve your problems.

Mad Max
A: 

Please be aware that I do have the distro with SQLite support. However it only has support for version 2, not 3.

My MicroApache version has SQLite 2 support [...]

I would like to use SQLite 3 because it is faster, I could interact with the databases I created for a project in Delphi and I could access the newly created databases with the Firefox extension SQLite Manager.

Alien426
A: 

Part 1 - (Having to add this post 1 section at a time due to site restrictions on posting links)

This page (link) which discusses the problem of connecting to SQLite 3 DBs and similar problems are covered. This may answer some of your queries:

http://www.issociate.de/board/post/469813/Connecting_to_SQLite3_database_from_PHP_5.25.html

The lastest build of Sqlite is compiled-in to PHP5 and is enabled via PDO.

It shows in PHPINFO.PHP as 2.0-dev "$Id: sqlite.c,v 1.166.2.13.2.12 2008/12/31 11:17:44 sebastian Exp $"

Mad Max
A: 

Part 2

(Having to add this post 1 section at a time due to site restrictions on posting links)

I'm sure you are aware that the SQLite developer renamed a number of the functions with the advent of SQLite3 including the open function - (See here http://sqlite.org/cintro.html) - I'm not sure how this has been handled by the PHP developers including this codebase into PHP. The suggestion from the page linked above is that you can open PHp3 DB's "as is" with the right PHP code.

Mixing DLLs from different distros of PHP isn't recommended. I don't recommend any other use of the MicroApache distro other than "as is". Adding or mixing DLLs from differing versions of PHP etc. to MicroApache may introduce serious bugs or security problems.

There has been little or no interest in SQLite with MicroApaceh to date so I've really not dug too deeply into it other than to check the functinality works. I don't rely too heavily on what's reported by PHPINFO. Perhaps you can feed back your info to confirm if the version being reported is accurate.

Mad Max
A: 

Part 3: (final)

There is an SQLite3.DLL included with the distro as a courtesy which can be accessed directly from VB5/6 or any compatible language which can call the DLL. This was a separate project I had a look at some while ago. This was produced in MSVC by editing the original source. http://vbtoolbox.kerys.co.uk/sqlite/index.htm - This DLL isn't compatible with PHP/PDO but could be used via a CGI interface. Alternately the original Sqlite 3 DLL could be obtained and used via Delphi etc.

Mad Max
A: 

I've had time to research a little more and this page answers your problem:

http://lists.macosforge.org/pipermail/macports-users/2009-January/013658.html

The PHP implementation is partial and not well documented. Some SQLite3 procedural function calls are only exposed by an object based heirarchy. The procedural API only offers the ability to open SQLite 2 DBs so you're stuck with using objects by the looks of it.

-- QUOTE 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:

-- UNQUOTE

Mad Max
A: 

I've tinkered with this problem some more, but could still not create/access a SQLite 3 database.

Interestingly, the link you provided in Part 1 mentions a class "SQLiteDatabase" which is not found in the PHP documentation and is not part of the SQLite3 extension (which is object oriented - as mentioned in your last post, Mad Max).

"SQLiteDatabase" creates a database, but when you open it, you can see that it is in version 2.1.

Thanks for the help.

EDIT:
PDO works only when I use the DSN prefix "sqlite2" which is not very surprising, since phpinfo() only lists the driver "sqlite2" under the section "PDO".

Alien426