[英]PHP 5.6.x lost ability to connect to ODBC source
I have a strange problem. 我有一个奇怪的问题。 My server has been running PHP 5.6 for years no problem.
我的服务器已运行PHP 5.6多年没问题。 (WinServer Std 2K8 SP2, IIS 6, MySQL 5.6 {separate server}, PHP 5.6)
(WinServer Std 2K8 SP2,IIS 6,MySQL 5.6 {独立服务器},PHP 5.6)
We connect it to a DB2 server at our parent company. 我们将它连接到我们母公司的DB2服务器。 Today (2017-02-14) the ODBC connection (PDO_ODBC) started returning "could not find driver".
今天(2017-02-14)ODBC连接(PDO_ODBC)开始返回“找不到驱动程序”。
Excel is able to use the same ODBC connection to query the database - the ODBC connection is working. Excel能够使用相同的ODBC连接来查询数据库 - ODBC连接正在运行。
I tried using both the PDO method and procedural method to connect. 我尝试使用PDO方法和程序方法进行连接。 Failures in seeing the driver both ways.
无法双向看到驾驶员。
From phpinfo()
: ODBC Data PDO Data 来自
phpinfo()
: ODBC Data PDO Data
Code snippet: 代码段:
$dsn = "odbc:workingODBCdsn";
$user = "xxxx";
$password = "yyyy";
$conn = null;
$results = array();
try {
$conn = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
die($e->getMessage());
}
if ($conn) {
$qry = $conn->query($sql);
if ($qry) {
$qry->setFetchMode(PDO::FETCH_ASSOC);
foreach ($qry as $row) {
$results[] = $row;
}
}
}
print "<pre>" . print_r($results, true) . "</pre>";
//ALT Method
$conn = odbc_connect($dsn, $user, $password);
$results = odbc_exec($conn, $sql);
print "<pre>" . print_r($results, true) . "</pre>";
Thanks in advance for any help. 在此先感谢您的帮助。
Are you using the unixODBC or ibm_db2 ( http://php.net/manual/en/ref.pdo-odbc.php )? 您使用的是unixODBC还是ibm_db2( http://php.net/manual/en/ref.pdo-odbc.php )? It it recommended to use IBM DB2 Universal Database with “ibm_db2” extension.
它建议使用带有“ibm_db2”扩展名的IBM DB2 Universal Database。 It's faster and more efficient than using generic driver.
它比使用通用驱动程序更快,更有效。 It calls the native IBM DB2 functions with the extension.
它使用扩展名调用本机IBM DB2函数。
Check out the db2_* functions from php.net IBM DB2 functions manual 从php.net IBM DB2函数手册中查看db2_ *函数
Server's PHP instance switched from IIS to IISExpress. 服务器的PHP实例从IIS切换到IISExpress。 Switching it back to (full) IIS, and enduring all appropriate PDO drivers were enabled fixed the problem.
将其切换回(完整)IIS,并启用所有适当的PDO驱动程序已启用修复此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.