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:
<?php
try {
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:
<?php
if (empty(PDO::getAvailableDrivers()))
{
throw new PDOException ("PDO does not support any driver.");
}
?>