Handle properly situation when PDO class doesn't exist

pull/18/head
Aleksander Machniak 13 years ago
parent 8c2375a074
commit e6e5cb12f5

@ -137,6 +137,11 @@ class rcube_db
// Connect // Connect
try { try {
// with this check we skip fatal error on PDO object creation
if (!class_exists('PDO', false)) {
throw new Exception('PDO extension not loaded. See http://php.net/manual/en/intro.pdo.php');
}
$this->conn_prepare($dsn); $this->conn_prepare($dsn);
$dbh = new PDO($dsn_string, $dsn['username'], $dsn['password'], $dsn_options); $dbh = new PDO($dsn_string, $dsn['username'], $dsn['password'], $dsn_options);
@ -144,7 +149,7 @@ class rcube_db
// don't throw exceptions or warnings // don't throw exceptions or warnings
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
} }
catch (PDOException $e) { catch (Exception $e) {
$this->db_error = true; $this->db_error = true;
$this->db_error_msg = $e->getMessage(); $this->db_error_msg = $e->getMessage();

Loading…
Cancel
Save