一、下载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 |
linux 下须要pdo_dblib 这个须要用到freetds
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-dblib=/usr/local/freetds