Connection parameters for Microsoft SQL Server in PHP

153
March 22, 2019, at 9:30 PM

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);
Answer 1

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().

Rent Charter Buses Company
READ ALSO
Paypal REST API with PHP SDK - How to get the transaction number?

Paypal REST API with PHP SDK - How to get the transaction number?

I'm using the REST API Paypal ExpressCheckout with the PHP SDK, my script is able to process payment but I would like to get a essential information about the payment : the transaction number, usefull for tracking payment

137
Format input string from unwanted characters

Format input string from unwanted characters

Hi how to format a string from unwanted characters in php? Tried strip_tags, mysqli_real_escape_string, but no success

111
Allow specific products to be only purchased once by user in Woocommerce

Allow specific products to be only purchased once by user in Woocommerce

The following code for Woocommerce, allows being purchased again once purchased

180