Add a Database::getType() function so that we can get rid of $wgDBtype in favour...
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 7 Jan 2010 00:22:18 +0000 (00:22 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 7 Jan 2010 00:22:18 +0000 (00:22 +0000)
includes/db/Database.php

index 059fa7c..ef1abfc 100644 (file)
@@ -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
 #------------------------------------------------------------------------------