如何在 windows 7 机器上连接 MSSQL 数据库和 Zend Framework 3?

How to connect MSSQL database with the Zend Framework 3 in windows 7 machine?

我正在尝试将 MSSQL 数据库与 Zend 框架 3 连接。

但是我已经在我的 windows 机器上用正常的 PHP 代码连接了 MSSQL。为此,我安装了 sqlsrv。

这是代码..

$serverName = "USER-PC\MYINSTANCE"; //serverName\instanceName
$connectionInfo = array( "Database"=>"MYSamples", "UID"=>"MYRawData", "PWD"=>"123456");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}

请帮我连接MSSQL数据库和Zend framework 3。

提前致谢

好的,我终于得到答案了。可能这个答案对某些人有帮助。

我对 local.php (config\autoload\local.php) 文件

进行了以下更改
<?php
use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver;

return [
   'doctrine' => [
       'connection' => [
           'orm_default' => [
               'driverClass' => SQLSrvDriver::class,
               'params' => [
                   'host'     => 'USER-PC\MYINSTANCE',                    
                   'user'     => 'MYRawData',
                   'password' => '123456',
                   'dbname'   => 'MYSamples',
                   'port'     => '49166'
               ]
           ],            
       ],        
   ],
];

请参阅此 link 以查找 mssql 端口号:Identify Port used by SQL Server Database Engine Using SQL Server Configuration Manager