简体   繁体   English

适用于iSeries IBM DB2的PHP PDO Windows

[英]PHP PDO Windows for iSeries IBM DB2

I am trying to get a PDO connection (php 5.4) on Windows 7 (64 bit) to connect to iSeries IBM AS/400. 我试图在Windows 7(64位)上获得PDO连接(php 5.4)以连接到iSeries IBM AS / 400。 My end goal is to use Yii2, which uses PDO. 我的最终目标是使用使用PDO的Yii2。

For PDO driver compatibility, I used php5.4, since php5.5 couldn't load the PDO extension for IBM_DB2. 为了兼容PDO驱动程序,我使用php5.4,因为php5.5无法加载IBM_DB2的PDO扩展。 I originally had the the IBM DB2 odbc driver running with PDO, using the following connection string: 最初,我使用以下连接字符串将IBM DB2 odbc驱动程序与PDO一起运行:

 try {
  $dbc = new PDO("ibm:DRIVER={IBM DB2 ODBC DRIVER};
         DATABASE=MYDB;"."HOSTNAME=myhost;", "myuser", "mypassword");
 } catch (PDOException $e) {
     print "Error!: " . $e->getMessage(). "<br/>";
     die();
 }

...but I was getting connection errors from the host. ...但是我从主机收到连接错误。 Maybe that is the wrong driver for iSeries? 也许这是iSeries的错误驱动程序?

I then found an iSeries Access ODBC driver in the install for IBM i Access for Windows, and thought this might be the driver needed instead. 然后,我在用于Windows的IBM i Access的安装中找到了iSeries Access ODBC驱动程序,并认为这可能是需要的驱动程序。 I had to do a system restore to get the iSeries Access ODBC driver working, but the restore uninstalled the other IBM DB2 ODBC driver. 我必须进行系统还原才能使iSeries Access ODBC驱动程序正常工作,但是还原已卸载了其他IBM DB2 ODBC驱动程序。 The iSeries Access ODBC driver now appears correctly. 现在,iSeries Access ODBC驱动程序可以正确显示。

However, now the PDO extension failed to load. 但是,现在PDO扩展无法加载。 It complained about db2cli.dll missing. 它抱怨db2cli.dll丢失。 In trying to fix thsi, it also re-installed the old IBM DB2 ODBC driver connection. 为了解决此问题,它还重新安装了旧的IBM DB2 ODBC驱动程序连接。 Note: I am still getting the error message. 注意:我仍然收到错误消息。

1) Will the IBM DB2 ODBC driver work with iSeries, and I just have the connection string wrong? 1)IBM DB2 ODBC驱动程序是否可以与iSeries一起使用,而我只是将连接字符串弄错了?

2) Does the missing db2cli.dll message indicate the PDO connectivity is indeed tied to the IBM DB2 ODBC driver? 2)缺少的db2cli.dll消息是否表明PDO连接确实与IBM DB2 ODBC驱动程序相关? I am wondering if the iAccess ODBC driver can/should be used with the PDO extension. 我想知道iAccess ODBC驱动程序是否可以/应该与PDO扩展一起使用。

Any help is appreciated. 任何帮助表示赞赏。 Thank you. 谢谢。

Both ODBC drivers are required, and the connection string is wrong. 两个ODBC驱动程序都是必需的,并且连接字符串错误。

1) To get rid of the db2cli.dll message, the odbc cli drivers had to be downloaded from IBM (in addition to the Client Access 7.1.zip for iSeries ODBC drivers), and then the path had to be updated manually to point to the db2cli.dll file. 1)要摆脱db2cli.dll消息,必须从IBM下载odbc cli驱动程序(除了iSeries ODBC驱动程序的Client Access 7.1.zip之外),然后必须手动更新路径以指向db2cli.dll文件。

2) The connection string is as follows: (include the curly brackets) 2)连接字符串如下:(包括大括号)

$dbc = new PDO("odbc:DRIVER={iSeries Access ODBC DRIVER}; ", 
    "SYSTEM={foobar}; ",  
    "DATABASE={dbname}; ", 
    "UID={foo}; ", 
    "PWD={bar}");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM