title: Php SQLSRV query timeout or login timeout
body: <p>I'm using Codeigniter 3.1 and connect to remote a mssql database. But sometimes mssql connect take long time and i want to set a query time out or mssql connect login time out. But seems it doesn't work for me.
  what i may have missed? </p>
  
  <p>My connect configuration;</p>
  
  <pre><code>try{
    $dsn ="sqlsrv:Server=IP,Port;Database=DB;";
    $db  = new PDO($dsn, "username", "password");
  
   //$db-&gt;setAttribute(PDO::SQLSRV_ATTR_QUERY_TIMEOUT, 3);
   //$db-&gt;setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION );
  
    $query=('select * from Accounting');
  
    $cmd = $db-&gt;prepare($query,array(PDO::SQLSRV_ATTR_QUERY_TIMEOUT =&gt; 1 ));
  
    if(!$cmd-&gt;execute()){
      throw new PDOException ($cmd-&gt;errorInfo());
    }
    return $cmd-&gt;fetchAll(PDO::FETCH_ASSOC);
  }catch(PDOException $e) {
    die("Error connecting to SQL Server: " . $e-&gt;getMessage());
  }
  </code></pre>
  
  <p><strong>Edit:</strong> I'm using this drive;
  <a href="https://docs.microsoft.com/en-us/sql/connect/php/pdo-sqlsrv-driver-reference?view=sql-server-ver15" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/sql/connect/php/pdo-sqlsrv-driver-reference?view=sql-server-ver15</a></p>
  
  <p>I create a loop sending query to db;</p>
  
  <pre><code>Name    Status  Type    Size        Time       Respose
  test    200      xhr    10.5kb     400ms       working well
  test    200      xhr    10.5kb     400ms       working well
  test    200      xhr    608kb      1.16ms      login time out
  test    200      xhr    10.5kb     400ms       working well
  test    200      xhr    10.5kb     400ms       working well
  test    200      xhr    618kb      39.45s      gives TCP error
  test    200      xhr    10.5kb     400ms       working well
  test    200      xhr    10.5kb     400ms       working well
  </code></pre>
  
  <p><strong>First time login timeout working but second time doesn't</strong></p>