User Contributed Notes 2 notes

Since the method is a static, one practice is using it to check whether a specific server database driver is available and configured correctly with PDO before establishing the connection:<?phptry { if (!in_array("mysql",PDO::getAvailableDrivers(),TRUE)) { throw new PDOException ("Cannot work without a proper database setting up"); }}catch (PDOException $pdoEx){ echo "Database Error .. Details :<br /> {$pdoEx->getMessage()}";}?>

or to check for any driver in general: <?phpif (empty(PDO::getAvailableDrivers())) { throw new PDOException ("PDO does not support any driver."); }?>