How to Query IBM i Data with PHP and PDO_ODBC

ODBC & Db2 for iOf the PHP extensions that can connect to IBM i Db2, we recommend PDO_ODBC whenever possible.

Although the classic extensions (ibm_db2, PDO_IBM) and older ODBC continue to work, we prefer PDO_ODBC for several reasons:

Example script using PDO_ODBC to query the sample QCUSTCDT table

We included try/catch blocks to demonstrate good error handling.

 

Note about special characters

If the User ID or Password contains a semicolon (;), wrap the value in curly braces:

More about PDO_ODBC

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.