php 鏈接sqlserver2008 mssql 官方 windows

一、下載php

https://www.microsoft.com/en-us/download/confirmation.aspx?id=20098linux

先看下本身的php版本號,而後放置對應的dll文件sql

E:\www\dingshang\shell>php -v
PHP 5.6.27 (cli) (built: Oct 14 2016 10:22:59)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

我這裏是5.6的,而後把上面的都下載下來,找到對應的文件 注意選用pdo的 shell

二、配置:bash

; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension
extension=php_pdo_sqlsrv_56_nts.dll
;extension=php_bz2.dll
extension=php_curl.dll
extension=php_imagick.dll
;extension=php_fileinfo.dll

 

三、鏈接方法app

http://cn2.php.net/manual/zh/ref.pdo-sqlsrv.connection.phpdom

host-ip: 10.4.2.50
host-name: mssqlhost.mydomain.org
mssql-server-name: foo-sql
mssql-instance-name: MSSQLSERVER
database-name: mydb

<?php

$dbh = new PDO("sqlsrv:Server=foo-sql,1433;Database=mydb", $user , $pass);

?>

 

四、提示錯誤,少了 ODBC Driver 11 for SQL Server for x86 curl

Failed to get DB handle: SQLSTATE[IMSSP]: This extension requires the Microsoft
ODBC Driver 11 for SQL Server to communicate with SQL Server. Access the followi
ng URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsof
t.com/fwlink/?LinkId=163712

 

直接下載安裝就能夠了ui

參考資料url

http://cn2.php.net/manual/zh/ref.pdo-dblib.php

http://cn2.php.net/manual/zh/ref.pdo-sqlsrv.php 這個更加準確點

 

linux 下須要pdo_dblib  這個須要用到freetds

./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-dblib=/usr/local/freetds
相關文章
相關標籤/搜索