With Seiden CommunityPlus+ PHP, you have a choice of IBM i Db2 database extensions: odbc, PDO_ODBC, ibm_db2, and PDO_IBM. By default, only odbc and PDO_ODBC are enabled, but you can easily enable ibm_db2 and PDO_IBM instead.

Within a single configuration, you may enable either the odbc extensions or the “classic” Db2 extensions (ibm_db2 and PDO_IBM). Under the IBM covers, the ODBC extensions and “classic” Db2 extensions use identically named APIs, so they won’t function properly if loaded simultaneously.

Prerequisites

Make sure the php-ibm_db2 and php-pdo_ibm packages are installed from Yum.

Using ODBC

PDO_ODBC and odbc are already enabled, by default, in CommunityPlus+ PHP.

Before creating a new site

If you’re just making the site, then you can pass siteadd the template used for classic database extensions before you make the site. (As mentioned, ODBC is the default.) First, install siteadd:

yum install siteadd

Then make the site, but use the classic database template and make a separate PHP configuration (so it doesn’t affect other sites):

addsite -p 8080 -n mysite -I -T template-legacy-db

Switching the extension automatically

If you have an existing site to switch, or want to do for the global PHP settings, you can use the toggle-db utility included as part of siteadd. First, install it:

yum install siteadd

Then run it with either “classic” (for ibm_db2 and PDO_IBM) or “odbc”; for example, to switch the global PHP settings to the classic databse extensions:

toggle-db -t classic

Or to switch a specific site to ODBC:

toggle-db -t odbc -d /www/mysite/phpconf/conf.d

Manually Using ibm_db2/PDO_IBM

If you can’t use the previous method, follow this instead. We use industry-standard .ini files to control our PHP extensions. By default, these .ini files will be in /QOpenSys/etc/php/conf.d. To enable ibm_db2 and PDO_IBM, edit these .ini files to comment out (add the semicolon) the odbc extensions, then remove the semicolon from (to uncomment) the Db2 extensions, like so:

  • 20-odbc.ini: Comment out the extension directive:;extension=odbc
  • 30-pdo_odbc.ini: Comment out the extension directive: ;extension=pdo_odbc
  • 99-ibm_db2.ini: Remove semicolon from the extension directive: extension=ibm_db2
  • 99-pdo_ibm.iniRemove semicolon from the extension directive: extension=pdo_ibm

Restart the web server. CP+ package updates will leave the configuration files alone when they’re changed, so you won’t need to change these files again after updates.

Enabling both types in parallel using a second web server

You can create a second web server instance that uses the other set of database extensions. Look at our instructions on how to do so automatically – tell siteadd to make a separate PHP configuration. When the new site is made, make the changes described in “Using ibm_db2/PDO_IBM,” above, except with the directory /www/SITE_NAME_HERE/phpconf/conf.d.