diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2013-05-27 20:32:02 -0400 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2013-05-27 20:32:02 -0400 |
commit | ee85e4d08ddb7e2ec03904c0893cf3dd464125fb (patch) | |
tree | 8b0065dc408466724ed93c726bf10dabe1a1b5d0 /lib/class/dba.class.php | |
parent | 914c903250de4837d3bf6e77e496c2a3ece5f638 (diff) | |
download | ampache-ee85e4d08ddb7e2ec03904c0893cf3dd464125fb.tar.gz ampache-ee85e4d08ddb7e2ec03904c0893cf3dd464125fb.tar.bz2 ampache-ee85e4d08ddb7e2ec03904c0893cf3dd464125fb.zip |
Change Dba::error() and audit its callers
Will hopefully return more useful information during installation, which
is the only place it's actually used and useful.
Diffstat (limited to 'lib/class/dba.class.php')
-rw-r--r-- | lib/class/dba.class.php | 12 |
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; } /** |