从IBM Cloud外部将php服务器连接到DB2 [英] Connecting php server to DB2 from outside IBM Cloud

查看:57
本文介绍了从IBM Cloud外部将php服务器连接到DB2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照此处描述的步骤进行操作:

解决方案

您的问题与编程无关,而与配置有关.

最好在每次寻求帮助时都详细说明您的php版本和linux发行版详细信息.

您已经成功配置了 db2dsdriver.cfg 并成功验证了与远程Db2数据库的CLI连接.这是必不可少的.

下一步是确保正确配置了ODBC和PHP.

这可能有助于验证以下所有项目:

  • 验证是否已安装php-odbc以匹配您的php版本.使用Linux发行版的package-manager(例如yum或apt等)来安装它,有很多页面可以帮助您.

  • 验证是否已启用php.ini:extension = odbc.so(对于Linux,似乎这不是php7的默认设置).

  • 验证命令行 php -m 是否显示odbc已加载

  • 如果您配置了unixODBC DSN,则请验证您是否可以在Linux上使用 isql 命令成功连接到DSN(以验证您的 odbc.ini 和<已使用Db2驱动程序和DSN详细信息正确配置了code> odbcinst.ini .使用 odbcinst -j 为您的发行版显示 odbc.ini odbcinst.ini 的路径.有很多页面显示如何配置这些文件以及如何运行 isql 命令行.DSN的使用是可选的,但它可以帮助进行完整性检查和集中化连接字符串,而不是将其复制到php脚本中.

  • 使用 php -m 命令行验证是否已加载ibm_db2驱动程序和pdo_ibm(如果使用PDO接口).

I am following the process as described here: https://www.ibm.com/support/knowledgecenter/en/SSHRBY/com.ibm.swg.im.dashdb.doc/connecting/connect_connecting_php.html

I have completed the instalation and I have even run the validation command in shell

db2cli validate -dsn DashDB -connect -user bluadmin -passwd 'your_secret_password'

see output below

But still my www page crashes on the line

$conn = odbc_connect( $conn_string, "", "" );

becasue it does not recognize the odbc_connect function.

Any feedback and hopefully help is very welcome.

解决方案

Your question is not about programming, but instead it is about configuration.

It is best if you detail your php version and your linux distro details fully every time you ask for help.

You already successfully configured db2dsdriver.cfg and successfully validated a CLI connection to the remote Db2 database. That is essential.

The next step is to ensure that both ODBC and PHP are configured appropriately.

It may help to verify all the following items:

  • Verify php-odbc is installed to match your version of php . Use the package-manager (e.g. yum or apt etc.) for your linux distro to install it, there's plenty of pages to help you with that.

  • Verify the php.ini has enabled: extension=odbc.so ( for Linux it seems this is not default with php7).

  • Verify that the command-line php -m shows that odbc is loaded

  • If you configured a unixODBC DSN then verify you can successfully connect to the DSN with isql command on linux (to verify that your odbc.ini and odbcinst.ini are properly configured with the Db2 driver and the DSN details). Use odbcinst -j to show the path to odbc.ini and odbcinst.ini for your distro. There's plenty of pages to show how to configure those files, and how to run the isql command line. Usage of a DSN is optional, but it can help with sanity checking and centralises the connection strings instead of having them replicated in php scripts.

  • verify the ibm_db2 driver is loaded and pdo_ibm (if using PDO interfaces) with the php -m command line.

这篇关于从IBM Cloud外部将php服务器连接到DB2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆