FreeTDS User Guide: A Guide to Installing, Configuring and Running FreeTDS | ||
---|---|---|
Prev | Chapter 5. How to get what works with it working | Next |
There are three options for building PHP with support for FreeTDS corresponding to the three APIs that FreeTDS supports: db-lib, ct-lib, and ODBC.
Note: All these examples build the CGI version. Consult PHP's documentation for building the Apache module and including other extensions.
db-lib is perhaps the most straightforward to build. Previously, some source code tweaking was required to build PHP with both db-lib and DBM support, but FreeTDS has handled that automatically since version 0.53.
First build FreeTDS normally.
$ ./configure --prefix=/usr/local/freetds $ make $ su root Password: $ make installThen build PHP with support for "Sybase"
$ cd php $ ./configure --with-sybase=/usr/local/freetds $ make $ su root Password: $ make installAnd that's it!
Option 2 is to use the ct-lib API. Again here, we run into minor difficulties at build time. Applications linking with Sybase's OpenClient have to link in a handful of libraries and these libraries vary slightly from platform to platform. When creating FreeTDS it was decided that there would be only one library: libct. This saves a great deal of library naming conflicts that Sybase ran into (e.g. libtcl is used both by Sybase and the language TCL), however some applications like PHP assume that all the Sybase libraries will be present. So, some hand editing of the Makefile is necessary to remove these extra libs. Build FreeTDS just as you would for db-lib in with db-lib, above. Then configure PHP with ct-lib.
$ cd php $ ./configure --with-sybase-ct=/usr/local/freetdsNow edit the Zend/Makefile looking for the libZend_la_LDFLAGS line and remove -lsybtcl -lintl -lcomn and -lcs, leaving the -lct. Then proceed to make and install PHP.
$ make $ su root Password: $ make installWe hope an upcoming version of PHP will automatically detect the presence of FreeTDS and include only the -lct library.
The third and newest option is to use the FreeTDS ODBC driver with PHP. This option is somewhat immature, so buyer beware. First build the iODBC driver manager and FreeTDS as detailed in this guide. Then build PHP with support for iODBC.
$ cd php $ ./configure --with-iodbc=/usr/local $ make $ su root Password: $ make installNow everything should run. There is a sample PHP script in the FreeTDS samples directory called odbctest.php.