ibm_db2 & ODBC Run Side-by-Side in Seiden CP+ PHP

Historically, PHP on IBM i implementations demanded loyalty to a single database connection style. You had to choose either the classic extensions (ibm_db2 / PDO_IBM) or the ODBC extensions (odbc / PDO_ODBC.) Operating system limitations prevented both types from being loaded at the same time.

In July 2021, we overcame those limitations to enable coexisting database extensions in Seiden CommunityPlus+ PHPYes, now the classic PHP database extensions can run side-by-side with ODBC! We will explain how this was done in a future blog post.

As of this writing, you’ll find this feature exclusively in CP+ PHP. When you install Seiden CP+, all db2 extensions (ibm_db2, PDO_IBM, odbc, and PDO_ODBC) are enabled by default.

Why is this important?

Many IBM i teams want to upgrade their PHP programs from the classic extensions to PDO_ODBC, the new standard for IBM i database connectivity. Previously, they would have to set up additional servers to migrate programs to ODBC piecemeal.

Now they can adopt ODBC without affecting existing applications. Then they can migrate at their own pace by using both connectivity types in the same application. For example, a single PHP script can use ibm_db2 for one query and PDO_ODBC for another.

How do I use this feature if I have an older CP+ package?

First, update to our current software, especially the latest php-ibm_db2, php-pdo_ibm, and siteadd packages. You can update them through ACS or through the command line like so:

$ yum update php-ibm_db2 php-pdo_ibm siteadd

After updating, you can enable all the Db2 extensions using the toggle-db command with the -t both flag. To do so for a specific site, point it to the site’s PHP extension INI directory:

$ toggle-db -t both -d /www/SITE_NAME_HERE/phpconf/conf.d

To enable these extensions globally for PHP-CLI and all sites using a global (not custom) configuration:

$ toggle-db -t both

If you have any questions, don’t hesitate to ask us.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.