From: Tim Starling Date: Thu, 7 Jan 2010 00:22:18 +0000 (+0000) Subject: Add a Database::getType() function so that we can get rid of $wgDBtype in favour... X-Git-Tag: 1.31.0-rc.0~38377 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=071bbbe2180ebab48a24abba781c4cec0c50ab37;p=lhc%2Fweb%2Fwiklou.git Add a Database::getType() function so that we can get rid of $wgDBtype in favour of OOP goodness. --- 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 #------------------------------------------------------------------------------