0

Good day, I am using wampserver, and I would like to get data from a remote IBM database (AS400) using db2_connect. I've tried searching on some ways but I couldn't get the idea of doing it. I have successfully included ibm_db2.dll extension on my php. However, I don't know what to do next.

7
  • Have you enabled the extension in php.ini? If no edit that file and add this line extension=ibm_db2.dll , assuming that is the file name of extension and that the file is inside the ext folder in php installation. Then you need to restart apache from wampserver and you can connect to database like this: $conn = db2_connect($database, $user, $password); Then you can use the functions: reference manual Commented Aug 31, 2017 at 5:25
  • Thank you very much for you answer. Sorry I forgot to indicate, yes I have enabled the extension in php.ini. db2 section is now on the php_info(); Commented Aug 31, 2017 at 5:31
  • what is the problem? Any error message if you try to connect? Commented Aug 31, 2017 at 5:33
  • there is: Unable to connect :[IBM][CLI Driver] SQL1531N The connection failed because the name specified with the DSN connection string keyword could not be found in either the db2dsdriver.cfg configuration file or the db2cli.ini configuration file. Data source name specified in the connection string: "AS400". SQLCODE=-1531 Commented Aug 31, 2017 at 5:34
  • You need to tell the DB2-client how to access the remote database by configuring the DB2-client , either by using command-lines or by manually editing config files. Do you know how to do this? Commented Aug 31, 2017 at 8:04

1 Answer 1

0

As you seem to be using "DB2 Connect" (and not a separate DB2 client) product you can either configure DB2-Connect with a node/alias/dsn and then mention that alias with the db2_connect() action, or use PDO_IBM longer connection string with all the details as mentioned here.

You need to know the tcpip-address (or hostname) of the i-Series DB2-server, and the Port-number it listens on.

Check this technote for the actions required to make a node/alias (I believe the same general configuration pattern applies to DB2-connect as Data server client).

The advantage of configuring like this is that you can verify the database-connect in your workstation command line shell , before making it work in PHP/pdo.

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.