I'm trying to connect MSSQL database with Zend framework 3.
But I have connected MSSQL with normal PHP code in my windows machine. For this I have installed sqlsrv.
Here is the code for that..
$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));
}
Please help me to connect the MSSQL database with Zend framework 3.
Thanks in advance
Okay finally I have got answer. May be this answer help some one.
I have made below changes on local.php (config\autoload\local.php) file
<?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'
]
],
],
],
];
Please refer this link to find the mssql port number : Identify Port used by SQL Server Database Engine Using SQL Server Configuration Manager