summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2014-09-18 18:30:46 +0100
committerGreg Roach <fisharebest@gmail.com>2014-09-18 18:30:46 +0100
commit054879f5ce18991f2e91d87a416098c94ea6c808 (patch)
tree731dff829d701bcc687fc505d663dd2e37ef7526 /library
parent3c972470cebf72a1e75c0d259c5b40b775c38c4c (diff)
downloadwebtrees-054879f5ce18991f2e91d87a416098c94ea6c808.tar.gz
webtrees-054879f5ce18991f2e91d87a416098c94ea6c808.tar.bz2
webtrees-054879f5ce18991f2e91d87a416098c94ea6c808.zip
Wrong exception type thrown in WT_DB
Diffstat (limited to 'library')
-rw-r--r--library/WT/DB.php19
1 files changed, 11 insertions, 8 deletions
diff --git a/library/WT/DB.php b/library/WT/DB.php
index 16b9d05bc6..18745b564d 100644
--- a/library/WT/DB.php
+++ b/library/WT/DB.php
@@ -30,8 +30,11 @@ class WT_DB {
// See http://en.wikipedia.org/wiki/Singleton_pattern
// See http://en.wikipedia.org/wiki/Decorator_pattern
//////////////////////////////////////////////////////////////////////////////
- private static $instance=null;
- private static $pdo=null;
+ /** @var WT_DB */
+ private static $instance;
+
+ /** @var PDO */
+ private static $pdo;
// Prevent instantiation via new WT_DB
private final function __construct() {
@@ -39,12 +42,12 @@ class WT_DB {
// Prevent instantiation via clone()
public final function __clone() {
- trigger_error('WT_DB::clone() is not allowed.', E_USER_ERROR);
+ throw new Exception('WT_DB::clone() is not allowed.');
}
// Prevent instantiation via serialize()
public final function __wakeup() {
- trigger_error('WT_DB::unserialize() is not allowed.', E_USER_ERROR);
+ throw new Exception('WT_DB::unserialize() is not allowed.');
}
// Disconnect from the server, so we can connect to another one
@@ -55,7 +58,7 @@ class WT_DB {
// Implement the singleton pattern
public static function createInstance($DBHOST, $DBPORT, $DBNAME, $DBUSER, $DBPASS) {
if (self::$pdo instanceof PDO) {
- trigger_error('WT_DB::createInstance() can only be called once.', E_USER_ERROR);
+ throw new Exception('WT_DB::createInstance() can only be called once.');
}
// Create the underlying PDO object
self::$pdo=new PDO(
@@ -180,10 +183,10 @@ class WT_DB {
}
// Add logging to query()
- public static function query($statement, $parameter_type= PDO::PARAM_STR) {
+ public static function query($statement) {
$statement=str_replace('##', WT_TBLPREFIX, $statement);
$start=microtime(true);
- $result=self::$pdo->query($statement, $parameter_type);
+ $result=self::$pdo->query($statement);
$end=microtime(true);
self::logQuery($statement, count($result), $end-$start, array());
return $result;
@@ -202,7 +205,7 @@ class WT_DB {
// Add logging/functionality to prepare()
public static function prepare($statement) {
if (!self::$pdo instanceof PDO) {
- throw new PDOException("No Connection Established");
+ throw new Exception("No Connection Established");
}
$statement=str_replace('##', WT_TBLPREFIX, $statement);
return new WT_DBStatement(self::$pdo->prepare($statement));