coffee_cn

博客园 首页 新随笔 联系 订阅 管理

Download the Microsoft Drivers for PHP for SQL Server

https://docs.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-2017

 

php.ini

extension=php_pdo_sqlsrv_71_nts_x64.dll
extension=php_sqlsrv_71_nts_x64.dll

 

$dbh = new PDO("sqlsrv:Server=192.168.168.33,1433;Database=My_DB", "username", "password");
$server = "192.168.168.33";
$coninfo = array("Database"=>"My_DB", "UID"=>"username", "PWD"=>"password");
$conn = sqlsrv_connect($server, $coninfo) or die ("连接失败!");
var_dump($conn);
sqlsrv_close($conn);

 

posted on 2019-06-15 16:41  coffee  阅读(348)  评论(0编辑  收藏  举报