0

I want to install the db2 extension for PHP on Windows but it just isn't working. I've tried a lot of different solutions but I still get these:

php.exe

phpinfo()

When I try connection to db2 database

I'm using Apache on XAMPP on port 80. I have installed this: https://github.com/ibmdb/php_ibm_db2/tree/master/PHP%207.4.x/x64/TS and placed it in my C:\xampp\php\ext folder and set "extension=php_ibm_db2.dll" in my php.ini file. (which is in C:\xampp\php)

Only "db2" appearing in phpinfo()

Variable where db2 is appearing

PATH variable

9
  • Look further down the phpinfo() output for a section that will itemise DB2 Commented Jan 27, 2022 at 14:26
  • Did you also download and install CLIDRIVER as described on github.com/php/pecl-database-ibm_db2 ? ( you only need this if you do NOT already have a db2 client on the PATH ). Commented Jan 27, 2022 at 14:27
  • See here for other requirements Commented Jan 27, 2022 at 14:28
  • idk wich one to install in the list. Is it --> ibm_db2-1.9.6.1.tar 03-Feb-2015 05:10 1.2M ? Commented Jan 27, 2022 at 14:30
  • 2
    Please use plain text, not pictures/graphics in your question. Is there a Db2-product already installed on the workstation? Give details, in plain text., in your question . The dependency looks like: php --> php_ibm_db2.dll --> db2 cli driver --> db2-server. Commented Jan 27, 2022 at 14:56

1 Answer 1

0

So, I did not manage to connect to my db2 DB with the db2 extension, but here's an alternative I've found -->

$database = "xxx";
$hostname = "xxx";
$user     = "xxx";
$password = "xxx";
$port     = 50000;

# Build the connection string
$driver  = "DRIVER={IBM DB2 ODBC DRIVER};";
$dsn     = "DATABASE=$database; " .
           "HOSTNAME=$hostname;" .
           "PORT=$port; " .
           "PROTOCOL=TCPIP; " .
           "UID=$user;" .
           "PWD=$password;";

$conn_string = $driver . $dsn;

# Connect

$conn = odbc_connect( $conn_string, "", "" );
if( $conn )
{
    echo "Connection succeeded.";
    odbc_close( $conn );
}
else
{
    echo "Connection failed.";
}

output --> Connection succeeded.

source --> https://www.ibm.com/docs/en/db2woc?topic=programmatically-php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.