title: PDO slow on PHP 5.4 and Apache 2.4.3
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11663860/mysql-connect-localhost-127-0-0-1-on-windows-platform">mysql_connect (localhost / 127.0.0.1) on Windows platform</a>  </p>
  </blockquote>
  
  
  
  <p>I just updated my Apache and PHP versions on a development machine and PDO has totally crapped out.</p>
  
  <p>This is the dead simple PDO class:</p>
  
  <pre><code>class PDO_DBH {
      public static function openSesame() {
          echo '&lt;p&gt;start openSesame: &lt;/p&gt;'.microtime(true);
          $db_username = 'root';
          $db_password = 'pass';
          try {
              $dbh = new PDO('mysql:host=localhost;dbname=DB_NAME', $db_username, $db_password);
              $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
              echo '&lt;p&gt;end successful openSesame: &lt;/p&gt;'.microtime(true);
              return $dbh;
          } catch (PDOException $e) {
              echo '&lt;p&gt;end failed openSesame: &lt;/p&gt;'.microtime(true);
              return 'PDO database access error!';
          }
      }
  }
  </code></pre>
  
  <p>Prior to upgrading, and currently on other dev machines, a typical page will load in a second, two at most.</p>
  
  <p>Now, via the wonders of <code>microtime(true)</code>, I am seeing each connection opening requires about a full second.</p>
  
  <p>A typical page may create a new <code>$dbh</code> and then <code>$dbh = null;</code> it 20 times as different objects and methods go about retrieving the data they need. This has never been a problem on other machines or on my webhost.</p>
  
  <p>Where have I gone wrong here?</p>