PHP中Microsoft SQL Server的连接参数

I'm trying to connect to Microsoft SQL Server with PHP

To work with a mirrored database in the sql management studio I use "ApplicationIntent=ReadOnly" in the "Additional Connection Parameters" label.

How can I set this parameter in php?

Example of how I'm connection without the parameter:

$serverName = "server, port";
$connectionInfo = array( "Database"=>"my_db");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

You can pass it as one of the options, like so:

sqlsrv_connect($serverName, ['ApplicationIntent' => 'ReadOnly']);

Or in your case:

$serverName = "server, port"; 
$connectionInfo = array('Database' => 'my_db', 'ApplicationIntent' => 'ReadOnly'); 
$conn = sqlsrv_connect( $serverName, $connectionInfo);

See also the php docs for sqlsrv_connect().