From 071bbbe2180ebab48a24abba781c4cec0c50ab37 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 7 Jan 2010 00:22:18 +0000 Subject: [PATCH] Add a Database::getType() function so that we can get rid of $wgDBtype in favour of OOP goodness. --- includes/db/Database.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/includes/db/Database.php b/includes/db/Database.php index 059fa7c84d..ef1abfc5eb 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -284,6 +284,17 @@ abstract class DatabaseBase { } } + /** + * Get the type of the DBMS, as it appears in $wgDBtype. + */ + function getType() { + if ( preg_match( '/^Database(\w+)$/', get_class( $this ), $m ) ) { + return strtolower( $m[1] ); + } else { + throw new MWException( get_class( $this ) .'::getType: unable to determine type.' ); + } + } + #------------------------------------------------------------------------------ # Other functions #------------------------------------------------------------------------------ -- 2.20.1