I am looking for an effective and fast method of checking the availability of an MSSQL db within PHP. Presently I am using the attached code to connect to the db.
If $conn returns false then I display an error. The problem is that often times this will time out or delay for a long period of time before reaching a false value. As a result I get inconsistent behavior.
How can I quickly check to see if the DB server is up and if not, display a message to the user and exit the code.
$connectioninfo = array("UID"=>$username,"PWD"=>$pw,"Database"=>$db,"ReturnDatesAsStrings"=> true);
$conn = sqlsrv_connect( $servername, $connectioninfo);