PDO Connection error handling slower than mysql_() ??

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Milkrunner
Forum Newbie
Posts: 1
Joined: Sat Jan 31, 2009 1:12 pm

PDO Connection error handling slower than mysql_() ??

Post by Milkrunner »

Hey,

I'm getting an error no matter how I do the error checking (I'm not worried about the error, I presume it's a database issue), but the PDO version resolves MUCH slower (~5 minutes) than the mysql_() one. ...? Also, I know I could just rewrite the mysql_() version to not use die() and accomplish the same thing, but I'm a fan of PDO and the majority of my code uses it.

Code: Select all

try
{
$dbh = new PDO("mysql:host=$forumdbhost;dbname=$forumdatabase", $forumdbuser, $forumdbpass);
}
catch (PDOException $e) { echo '<p>Database is down.</p>'; }

Code: Select all

if (!($db = mysql_connect($forumdbhost, $forumdbuser, $forumdbpass , $forumdatabase))){
      die("Can't connect to database server.".mysql_error());
    }else{
      // select a database
        if (!(mysql_select_db($forumdatabase,$db))){
          die("Can't connect to database.");
        }
    }
The error is:
SQLSTATE[HY000] [2003] Can't connect to MySQL server on '***.****.com' (110)
Post Reply