Discussion:
Cannot load PHP DB2 Module under Linux
(too old to reply)
v***@vanhoof.com
2007-09-18 19:51:26 UTC
Permalink
We have a system running Fedora Core 5 (2.6.18-1.2257.fc5) with Apache/2.2.2 and PHP 5.2.4. DB2 is installed as follows:

DB21085I Instance "db2inst1" uses "32" bits and DB2 code release "SQL08022"
with level identifier "03030106".
Informational tokens are "DB2 v8.1.2.88", "s050422", "MI00117", and FixPak "9".
Product is installed at "/opt/IBM/db2/V8.FP9".

Per http://us.php.net/ibm_db2 we did the following to install the "real" IBM DB2 driver for PHP:

pecl install ibm_db2

We have tried building this version of PHP with the following commands:

/home/db2inst1/sqllib/db2profile
/configure --with-ibm-db2=/home/db2inst1/sqllib --sysconfdir=/etc

The build test gave these, but I believe them to be non-critical:

Bug #16069 (ICONV transliteration failure) [ext/iconv/tests/bug16069.phpt]
iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt]
Bug #41655 (open_basedir bypass via glob()) [ext/standard/tests/file/bug41655_1.phpt]

We have added/edited the following in /etc/php.ini:

extension=ibm_db2.so
ibm_db2.instance_name db2inst1
ibm_db2.binmode 1
ibm_db2.i5_allow_commit 0
ibm_db2.i5_dbcs_alloc 0

We wrote a test program (I've not included the Apache details, as Apache is, in fact, processing the PHP correctly):

<?php
$database = 'XXXXX'; # Appropriate DB here
$user = 'db2inst1';
$password = 'xxxxxxxx';# Appropriate pass for db2inst1 here

$conn = db2_connect($database, $user, $password);

if ($conn) {
echo "Connection succeeded.";
db2_close($conn);
}
else {
echo "Connection failed.";
}
?>

But we get: Fatal error: Call to undefined function db2_connect() in /var/www/html/php/db2_test.php on line 6

And in the apache log: PHP Fatal error: Call to undefined function db2_connect() in /var/www/html/php/db2_test.php on line 6

We have Googled this and no one can give a straight answer on what's wrong, here. Can ANYONE shed any light on why this is occurring???
v***@vanhoof.com
2007-09-20 13:34:03 UTC
Permalink
BUMP.

Also, more info. php -m does NOT show the ibm_db2.so loaded. Further phpinfo() does NOT show it on the config, which (as you see from the original post) I *explicitly* put in there. Whiskey Tango Foxtrot, over?

Output from php -m:
[PHP Modules]
ctype
date
dom
filter
hash
iconv
json
libxml
odbc
pcre
PDO
pdo_sqlite
posix
Reflection
session
SimpleXML
SPL
SQLite
standard
tokenizer
xml
xmlreader
xmlwriter

[Zend Modules]

Output from phpinfo() is attached.
Knut Stolze
2007-09-24 13:57:42 UTC
Permalink
Post by v***@vanhoof.com
We have a system running Fedora Core 5 (2.6.18-1.2257.fc5) with
DB21085I Instance "db2inst1" uses "32" bits and DB2 code release
"SQL08022" with level identifier "03030106".
Informational tokens are "DB2 v8.1.2.88", "s050422", "MI00117", and FixPak
"9". Product is installed at "/opt/IBM/db2/V8.FP9".
Per http://us.php.net/ibm_db2 we did the following to install the "real"
pecl install ibm_db2
/home/db2inst1/sqllib/db2profile
/configure --with-ibm-db2=/home/db2inst1/sqllib --sysconfdir=/etc
Bug #16069 (ICONV transliteration failure) [ext/iconv/tests/bug16069.phpt]
iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt]
Bug #41655 (open_basedir bypass via glob())
[ext/standard/tests/file/bug41655_1.phpt]
extension=ibm_db2.so
ibm_db2.instance_name db2inst1
ibm_db2.binmode 1
ibm_db2.i5_allow_commit 0
ibm_db2.i5_dbcs_alloc 0
We wrote a test program (I've not included the Apache details, as Apache
<?php
$database = 'XXXXX'; # Appropriate DB here
$user = 'db2inst1';
$password = 'xxxxxxxx';# Appropriate pass for db2inst1 here
$conn = db2_connect($database, $user, $password);
if ($conn) {
echo "Connection succeeded.";
db2_close($conn);
}
else {
echo "Connection failed.";
}
?>
But we get: Fatal error: Call to undefined function db2_connect() in
/var/www/html/php/db2_test.php on line 6
And in the apache log: PHP Fatal error: Call to undefined function
db2_connect() in /var/www/html/php/db2_test.php on line 6
We have Googled this and no one can give a straight answer on what's
wrong, here. Can ANYONE shed any light on why this is occurring???
I haven't used this DB2 PHP driver yet, but for the old (and buggy) ODBC
driver, it was necessary to source the db2profile from the PHP profile (I
don't recall the exact name of that file).
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Loading...