Our Favorite ibm_db2 Settings for PHP
When supporting our Seiden CP+ PHP, we found that documentation for the “classic” ibm_db2 extension for IBM i wasn’t easy to find.
To help ourselves as well as others, we updated the PHP.net manual to describe each ibm_db2.i5_*
setting. This blog post links to that manual page and highlights a few of our favorite ibm_db2 settings.
Where to find all the ibm_db2 settings
The complete list can be found at https://www.php.net/manual/en/ibm-db2.configuration.php. Like PHP, the php.net manual itself is open source, so we recommended descriptions for each of the ibm_db2 settings. The community then entrusted our own Calvin Buckley to edit the PHP manual with guidance from other community members.
Some especially useful settings
We frequently recommend the following settings. Two are so helpful that we enable them by default in our own PHP distribution.
- ibm_db2.i5_char_trim: When set to 1, PHP will trim spaces from the ends of strings. Traditionally, because many Db2 for i tables use fixed-length character columns, PHP developers have used PHP’s trim() function, but this setting trims spaces automatically. By default, this option is 0.
- ibm_db2.i5_log_verbose: When set to 1, detailed SQL warnings and errors are logged into the PHP error log. Although the open source default is 0, Seiden CP+ PHP sets this to 1 by default to make it easier for programmers to find SQL errors.
- ibm_db2.i5_blank_userid: When set to 1, the programmer may provide a blank user id and password, as in
db2_connect('', '', '');
, in which case the job’s current user profile (usually QTMHHTTP if a web application) will be used. Although the open source default is 0, Seiden CP+ PHP sets this to 1 by default for backward compatibility with Zend Server and traditional coding patterns. - ibm_db2.i5_dbcs_alloc: When set to 1, provides a larger buffer when fetching data, which can help prevent truncation during conversion from EBCDIC to UTF-8 or other character set. Defaults to 0.
Where to find ibm_db2.ini
The location of ibm_db2.ini depends on your PHP distribution.
If you use Seiden CP+ PHP, look in /QOpenSys/etc/php/conf.d/99-ibm_db2.ini
. In addition, our automatic configuration tool, siteadd, provides one at the application level. E.g. /www/myserver/phpconf/conf.d/99-ibm_db2.ini
.
If anyone is curious, the source code for the ibm_db2 extension can be found at https://github.com/php/pecl-database-ibm_db2/.
Leave a Reply
Want to join the discussion?Feel free to contribute!