microcosmotalk.com
This article describes how to install an SQLite database behind an Apache webserver. PHP represents the server-side technology (application) running under an Apache web-server. It applies to Windows operating systems only. This does NOT apply to Unix or Linux operating systems.
First, check out the minimum requirements.
Next, decide upon which version of SQLite you want to configure PHP for.
- Configure PHP for SQLite 2
- Configure PHP for SQLite 3 (a.k.a. PDO SQLite)
- Configure PHP for both versions (SQLite 2 & SQLite 3)
Note: SQLite 3 gets referenced under two different names at the PHP website. The folks at PHP introduced some confusion by refering to SQLite 3 as PDO SQLite. The Apache guru's named the DLLs php_pdo_sqlite.dll (PDO SQLite (SQLite Version 3)) and php_sqlite.dll (SQLite Version 2).
Windows Requirements
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
A Windows Operting System. These instructions apply to Windows 2000/XP and Windows NT 4.0 only. Other Microsoft operating systems may not provide satisfaction. While PHP and Apache both work with Linux and other such operating systems, this information applies only to the Windows operating system.
An Apache Web Server (version 1.3.34 or better) previously installed. Manually Install An Apache HTTP Server Onto Windows.
Tested successfully with PHP (5.2.0).
PHP 5.2.0 (cli) (built: Nov 2 2006 11:57:36) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
Installing SQLite and getting SQLite to work with PHP ends up as an easy task.
SQLite 2
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
SQLite 2 cannot read SQLite 3 files. So think about this before making a decision.
To install SQLite 2, you need to open your PHP.INI file and either add a line or uncomment a line.
extension=php_pdo.dll extension=php_sqlite.dll
Without extension=php_pdo.dll, PHP writes a warning to php_error.log. The warning message PHP presents gets written silently to the error log, so get to know where your error log file gets written.
A file, named "sqlite2.api", lists of the available SQLite 2 functions. This file is placed in the public domain and represents a valid documented list of the API functions employed by SQLite Version 2.x. It provides the function drop-down lists for the SciTE editor but it's small and readable enough to be of use to everyone. For extra help with the functions, see SQLite 2 Function Reference.
Configure the extension_dir properly.
SQLite 3 (PDO SQLite)
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
From a page straight out of php.net, "SQLite 3 is supported through PHP 5.2 PDO Class".
To get SQLite 3 working with PHP, edit your PHP.INI file and either add these two lines or uncomment them. Make sure they retain the order as listed here.
extension=php_pdo.dll extension=php_pdo_sqlite.dll
Configure the extension_dir properly.
By the way, we tried getting the sqlite3.dll from SQLite Website to work inside of PHP. Unfortunately PHP dislikes non-PHP dlls. It appears that DLLs must get built with some special internal functions for PHP to recognize them.
These details subject to change.
SQLite 2 And 3
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
To get this working add/uncomment the following lines to your PHP.INI file.
extension=php_pdo.dll extension=php_pdo_sqlite.dll extension=php_sqlite.dll
Configure the extension_dir properly.
SQLite Constants
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
Add the following to the PHP.properties file under the CONSTANTS heading.
SQLITE_ASSOC \ SQLITE_BOTH \ SQLITE_NUM \ SQLITE_OK \ SQLITE_ERROR \ SQLITE_INTERNAL \ SQLITE_PERM \ SQLITE_ABORT \ SQLITE_BUSY \ SQLITE_LOCKED \ SQLITE_NOMEM \ SQLITE_READONLY \ SQLITE_INTERRUPT \ SQLITE_IOERR \ SQLITE_CORRUPT \ SQLITE_NOTFOUND \ SQLITE_FULL \ SQLITE_CANTOPEN \ SQLITE_PROTOCOL \ SQLITE_EMPTY \ SQLITE_SCHEMA \ SQLITE_CONSTRAINT \ SQLITE_TOOBIG \ SQLITE_MISMATCH \ SQLITE_MISUSE \ SQLITE_NOLFS \ SQLITE_AUTH \ SQLITE_ROW \ SQLITE_DONE \
PHP.INI
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
Apache Version 1.nn
Make sure the PHP.INI resides in the C:\WINDOWS or C:\WINNT folder.
php.net Configuring PHP on Apache 1.x (MS Windows)
Apache Version 2.nn
Use the PHPIniDir. See example below.
# configure the path to php.ini PHPIniDir "C:/php"
php.net Configuring PHP with Apache 2.x (MS Windows)
extension_dir
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
Next, set the path to the extensions proper. It appears in the PHP.INI file as the following line of text.
extension_dir=C:\path_to\php\ext
Your php dll files must reside in the designated path.
error_log
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
This brings up a minor gripe about the PHP.INI file. Lines loading extensions (extension=) do not get a space character before nor after the equal symbol (=). However, many other lines (e.g. error_log) contain a space character both before and after. When searching for anything in the PHP.INI file, take the placement of spaces around the equal symbol (=) into consideration, or simply do not include the equality symbol in the search.
To find where PHP errors get logged, open your PHP.INI file and look for the line that contains error_log.
SQLite And SciTE
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
If you use the SciTE editor to edit documents, the following file helps with the drop down lists and such for SQLite. Feel free to use it as you like. Edit PHP.properties (or PHPFunctions.properties) to include the Appropriate SQLite API File.
Available currently exclusively from MicroCosmoTalk... we place these files into the public domain with no restrictions placed upon them.
SciTE API Files
sqlite2.api And sqlite3.api
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
SQLite 2 API file: The Sqlite2.api File.
SQLite 3 (a.k.a. PDO SQLite) API file: The Sqlite3.api File.
Look for the following line inside your php.properties (or phpfunctions.properties) file. Specifically search for "api.$(file.patterns.php)" (without the quotes).
Change the line to read as below. NOTE the backslash characters are just line-continuation characters, they can be removed if so desired, to make a single line out of the lines below.
api.$(file.patterns.php)=\ $(SciteDefaultHome)\php.api;\ $(SciteDefaultHome)\sqlite2.api;\ $(SciteDefaultHome)\sqlite3.api
Finally, put The Sqlite2.api File and The Sqlite3.api File into the $(SciteDefaultHome) folder.
SQLite Database Browser
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
The SQLite Database Browser (1) fails to read from SQLite 2 data files created by Installing SQLite 2. Install Installing SQLite 3 (a.k.a. PDO SQLite) to use the database browser.
References
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
SQLite Database Browser (1)
SQLite Database Browser (2)
SQLite Website
SQLite 2 Function Reference
SQLite 3 (a.k.a. PDO SQLite) Function Reference
PHP 5.2
PHP 5.2 And SQLite.
PHP 5.2 PDO Class
Apache HTTP Server
Apache Web Server
Google Groups (alt.comp.lang.php)
Manually Install An Apache HTTP Server Onto Windows.
The Sqlite2.api File
The Sqlite3.api File
SciTE (The Scintilla Editor)
Installing SQLite 2
Installing SQLite 3 (a.k.a. PDO SQLite)
SQLite Reference Manual (php.net)
Appropriate SQLite API File
Acknowledgements
Top | Minimum Requirements
SQLite 2 | SQLite 3 | SQLite 2 And SQLite 3
PHP.INI | extension_dir | error_log
SciTE (Scintilla Editor) | SQLite Database Browser
References | Acknowledgements
Thanks to all who make this website possible. And thanks to those at SQLite.org.
From sqlite.org...
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
We add...
May you work hard and experience enlightenment.
Enjoy! If you find this information useful or see anything interesting in our sponsors to the left and right, please take a look.
