How to use Firebird with PHP?


Here's a short HOWTO for PHP4 and PHP5. If you run Debian or Ubuntu and PHP5, read FAQ #234.

The simplest way of adding Firebird support is adding the interbase module to an existing PHP installation. On Windows it's a matter of simply unpacking the PHP .zip package and extracting the PHP_INTERBASE.DLL extension, or choosing the Interbase package while installing from setup.exe installer. Please note that in the latter case, the installer might also install the old gds32.dll from InterBase 6.0, which you need to delete manually and replace with Firebird's fbclient.dll (just rename it to gds32.dll). On Linux, you need to compile the interbase.so module. It is done like this:

1. install php-devel package (needed for phpize. If you already have phpize command, you don't need it)
2. get the php source code for the exact version as you are running
3. unpack the source and go to ext/interbase directory
4. run: phpize
5. run: ./configure --with-interbase=shared,/opt/firebird
6. run: make
7. this will create interbase.so module (most probably in .libs subdirectory)

The following steps apply for Windows as well:

8. copy the module (.so or .dll) to /usr/lib/php/extensions (or whatever is the 'extension_dir' setting in php.ini)
9. uncomment the ;extension=php_interbase.dll in php.ini
10. restart Apache if you are using PHP with it

If you are not sure where is php.ini on your system, you can create a small PHP script that calls PHP internal function phpinfo(); and read it's output. You can use the same function to determine whether your extension has loaded properly.

Please note that php.ini in some of the Linux distributions does not have the section with extensions, but rather have a separate .ini files for extensions. You can find paths for some popular distributions on this page:
http://www.enquirysolve.co.uk/wiki/index.php?page=Linux+Manual+-+FLAP+Setup

Here's a set of tests to see if you extension is working properly:
http://fbexport.sourceforge.net/ibtest.php.txt

Please note that PHP5.x has a bug regarding NUMERIC(18,7) and other datatypes with precision higher than 6. The bug has been reported to PHP bug tracker, but is not fixed yet (PHP 5.2.3).


Do you find this FAQ incorrect or incomplete? Please e-mail us what needs to be changed. To ensure quality, each change is checked by our editors (and often tested on live Firebird databases), before it enters the main FAQ database. If you desire so, the changes will be credited to your name. To learn more, visit our add content page.



All contents are copyright © 2007-2024 FirebirdFAQ.org unless otherwise stated in the text.


Links   Firebird   News   FlameRobin   Powered by FB: Home Inventory   Euchre  
Add content   About  

Categories
 Newbies
 SQL
 Installation and setup
 Backup and restore
 Performance
 Security
 Connectivity and API
 HOWTOs
 Errors and error codes
 Miscellaneous