title: Connections in loop for SQL Server Symfony2
body: <p>i´ve been trying to create a loop for different MSSQL Server in Symfony 2.3, but if some of the servers is off or the MSSQL service is down, the app don’t make an exception and it breaks the function.</p>
  
  <p>This is the main controller:</p>
  
  <pre><code>function pruebaconAction()
  {
      $enlistaServers = new array (
                                   10.10.10.1, 
                                   10.10.10.2, 
                                   10.10.10.3, 
                                   ...
                                   10.10.10.19,
                                   10.10.10.20
                                  );
  
      foreach($enlistaServers as $datosServer)
      {
          $direccionIPParaConexion = $datosServer-&gt;getDireccionIp ();
          $nombreLocalidad = $datosServer-&gt;getNombre();
          register_shutdown_function(array($this, 'conectaSrv'), $direccionIPParaConexion, $nombreLocalidad);
      }
      return $this-&gt;render("GastoEnlaceBundle:Default:pruebacon.html.twig");
  }
  </code></pre>
  
  <p>This function create the conection:</p>
  
  <pre><code>function conectaSrv($direccionIpConexion, $nombreLocalidad)
  {
      $pruebaDBAL = new \Doctrine\DBAL\Configuration();
      $parametrosConexion = array(
          'dbname' =&gt; 'MyDB',
          'user' =&gt; 'user',
          'password' =&gt; 'password',
          'host' =&gt; $direccionIpConexion,
          'driver' =&gt; 'pdo_sqlsrv'
      );
      $conexionDBAL = DriverManager::getConnection($parametrosConexion, $pruebaDBAL);
      if($conexionDBAL-&gt;connect())
          echo "Success&lt;br /&gt;";
      else
          throw new Exception("Something is wrong :(&lt;br /&gt;");
      echo "=======================================================================&lt;br /&gt;";
  }
  </code></pre>
  
  <p>I Always get the same result, for all the servers on line, the connection is sucessfully but if some of the servers is offline the function never send an exception and it breaks the loop.</p>
  
  <p>I hope someone can help me or give an advice, thanks a lot.</p>