summaryrefslogtreecommitdiffstats
path: root/lib/class/dba.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/class/dba.class.php')
-rw-r--r--lib/class/dba.class.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php
index 55608f76..96b313bc 100644
--- a/lib/class/dba.class.php
+++ b/lib/class/dba.class.php
@@ -39,6 +39,7 @@ class Dba {
public static $stats = array('query'=>0);
private static $_sql;
+ private static $_error;
private static $config;
/**
@@ -89,10 +90,12 @@ class Dba {
self::$stats['query']++;
if (!$stmt) {
+ self::$_error = json_encode($dbh->errorInfo());
debug_event('Dba', 'Error: ' . json_encode($dbh->errorInfo()), 1);
self::disconnect();
}
else if ($stmt->errorCode() && $stmt->errorCode() != '00000') {
+ self::$_error = json_encode($stmt->errorInfo());
debug_event('Dba', 'Error: ' . json_encode($stmt->errorInfo()), 1);
self::disconnect();
return false;
@@ -248,6 +251,7 @@ class Dba {
$dbh = new PDO($dsn, $username, $password);
}
catch (PDOException $e) {
+ self::$_error = $e->getMessage();
debug_event('Dba', 'Connection failed: ' . $e->getMessage(), 1);
return null;
}
@@ -267,6 +271,7 @@ class Dba {
}
if ($dbh->exec('USE `' . $database . '`') === false) {
+ self::$_error = json_encode($dbh->errorInfo());
debug_event('Dba', 'Unable to select database ' . $database . ': ' . json_encode($dbh->errorInfo()), 1);
}
@@ -286,6 +291,7 @@ class Dba {
$dbh = self::_connect();
if (!$dbh || $dbh->errorCode()) {
+ self::$_error = json_encode($dbh->errorInfo());
return false;
}
@@ -390,11 +396,7 @@ class Dba {
* this returns the error of the db
*/
public static function error() {
- $dbh = self::dbh();
- if ($dbh) {
- return $dbh->errorCode();
- }
- return false;
+ return self::$_error;
}
/**