When testing PHP with Easysoft's SQL Server ODBC driver, we found that a later version of PHP's PDO ODBC extension was more reliable than the one that came with the test machine's Linux distribution.
The version of PDO ODBC on the PHP git repository contains important changes for 64-bit platforms. Another benefit for users on 64-bit platforms is that they can build PDO ODBC against a version of unixODBC that is included with their ODBC driver, ensuring that extension, Driver Manager and ODBC driver have the same size SQLLEN types.
To minimise disruption to our system, we wanted to retain our existing version of PHP and only upgrade PDO ODBC, which on our machine was one shared object. However, our attempt to do this failed because there is a mechanism in PHP that prevents the use of an extension that has been compiled against a different version of PHP. We got this error message:
PHP Warning: PHP Startup: PDO_ODBC: Unable to initialize module Module compiled with module API=20131227 PHP compiled with module API=20121212 These options need to match
To work around this, we:
$ php --version PHP 5.5.9-1ubuntu4.3 (cli)
You can also use the phpinfo()
function to find out the PHP version.
$ git clone https://github.com/php/php-src.git
$ gunzip php-5.5.9.tar.gz $ tar -xvf php-5.5.9.tar $ cd php-5.5.9/ext $ mv pdo_odbc pdo_odbc_5_5_9 $ mv ../../php-src/ext/pdo_odbc .
$ cd .. ./configure --with-pdo-odbc=shared,unixODBC,/usr/local/easysoft/unixODBC $ make
$ cd /usr/lib/php5/20121212 $ sudo mv pdo_odbc.so pdo_odbc.so_5_5_9 $ cd - $ sudo cp modules/pdo_odbc.so /usr/lib/php5/20121212