Possible Duplicate:
mysql_connect (localhost / 127.0.0.1) on Windows platform
I just updated my Apache and PHP versions on a development machine and PDO has totally crapped out.
This is the dead simple PDO class:
class PDO_DBH {
public static function openSesame() {
echo '<p>start openSesame: </p>'.microtime(true);
$db_username = 'root';
$db_password = 'pass';
try {
$dbh = new PDO('mysql:host=localhost;dbname=DB_NAME', $db_username, $db_password);
$dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
echo '<p>end successful openSesame: </p>'.microtime(true);
return $dbh;
} catch (PDOException $e) {
echo '<p>end failed openSesame: </p>'.microtime(true);
return 'PDO database access error!';
}
}
}
Prior to upgrading, and currently on other dev machines, a typical page will load in a second, two at most.
Now, via the wonders of microtime(true)
, I am seeing each connection opening requires about a full second.
A typical page may create a new $dbh
and then $dbh = null;
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.
Where have I gone wrong here?