Thread Safety enabledPDO drivers mysql, oci, odbc, sqlite, sqlsrvpdo_sqlsrv
pdo_sqlsrv support enabled
Directive Local Value Master Value
pdo_sqlsrv.client_buffer_max_kb_size 10240 10240
pdo_sqlsrv.log_severity 0 0以上是PHPINFO中的信息在WAMP中已经开启扩展,以下是连接代码
<?php
try {
$hostname = "127.0.0.1";
$dbname = "ABIS_FOOD";
$username = "sa";
$pwd = "123456";
$dsn = "sqlsrv:Server=$hostname;database=$dbname";
$conn = new \PDO($dsn, $username, $pwd);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "mssql database connnection sucessed!";
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit();
}运行时提示出错信息Failed to get DB handle: SQLSTATE[IMSSP]: This extension requires the ODBC Driver 11 for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712请过来人指点一下。多谢祝大家新年愉快,万事如意
已经解决了,在WIN下原来还需要装一个msodbcsql.msi
最佳答案