I have read on IBM pages that DB2 can be used with Drupal. However, there is no detailed documentation to follow.

I am trying to use DB2 V9.5 with Drupal 6. But I am having a difficult time making it work.

I have recompiled PHP 5, using extension IBM_DB2. I have run a sample PHP test program which connects to a DB2 database and performs SQL insert,update and delete statements. I discovered that Drupal, as part of the installation process, requires that DB2 installation script /includes/install.ibmdb2.inc be present so that Drupal can create a temporary table and perform similar SQL statements. So far so good: PHP talks to DB2 and PHP/DB2 runs in Drupal.

However, Drupal has one more requirement: it tests to see whether DB2 conforms to its database abstraction layer. It does this by running various tests against file /includes/database.ibmdb2.inc. At this point I run out of luck and I receive the following error messages:

PHP Warning: db2_exec() [function.db2-exec]: Statement Execute Failed in /var/www/html/includes/database.ibmdb2.inc on line 90
[Mon Mar 23 12:21:57 2009] [error] [client 127.0.0.1] PHP Warning: [IBM][CLI Driver][DB2/LINUX] SQL0132N A LIKE predicate or POSSTR scalar function is not valid because the first operand is not a string expression or the second operand is not a string. A LOCATE or POSITION scalar function is not valid because the first operand is not a string or the second operand is not a string expression. SQLSTATE=42824 SQLCODE=-132\nquery: SELECT O.* FROM (SELECT I.*, ROW_NUMBER() OVER () sys_row_num FROM (SELECT 1 FROM access WHERE type = 'host' AND LOWER('127.0.0.1') LIKE LOWER(mask) AND status = 0) AS I) AS O WHERE sys_row_num BETWEEN 0 AND 1 in /var/www/html/includes/database.ibmdb2.inc on line 111

I am puzzled by two questions:
1) Where was that statement generated? At the time of the error, Drupal is reporting on a query that was created somewhere else.
and
2) How did Drupal come up with that bizarre syntax?.As you will see below, MySQL produces a more friendly statement

I reran my installation using MySQL in order to trap its version of that Select statement. Here is what I found:

SELECT 1 FROM access WHERE type = 'host' AND LOWER('127.0.0.1') LIKE LOWER(mask) AND status = 0 LIMIT 0, 1

Now, of course, Drupal plays nice with MySQL because it was designed to work with MySQL. But what about DB2 and what does it take use it? Do any of you have experience using DB2 with Drupal? If so, can you supply me with a list of tasks and/or modifications I need?

Comments

This would make running Drupal in our enterprise environment SO much easier