Database table name is now guessed if not set
authorAlexander Ebert <ebert@woltlab.com>
Mon, 20 Feb 2012 13:30:30 +0000 (14:30 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 20 Feb 2012 13:30:30 +0000 (14:30 +0100)
wcfsetup/install/files/lib/data/DatabaseObject.class.php

index b2cddd2068bea61ea0e10c0db06fc9fb15d27c1f..16ade9df48e5f6163b1e92daee8135d07b2ff5cd 100644 (file)
@@ -112,6 +112,20 @@ abstract class DatabaseObject implements IStorableObject {
         * @see wcf\data\IStorableObject::getDatabaseTableName()
         */
        public static function getDatabaseTableName() {
+               if (empty(static::$databaseTableName)) {
+                       $className = get_called_class();
+                       $className = substr($className, (strrpos($className, '\\') + 1));
+                       
+                       preg_match_all('~((?:^|[A-Z])[a-z]+)~', $className, $matches);
+                       foreach ($matches[1] as $part) {
+                               if (!empty(static::$databaseTableName)) {
+                                       static::$databaseTableName .= '_';
+                               }
+                               
+                               static::$databaseTableName .= strtolower($part);
+                       }
+               }
+               
                return 'wcf'.WCF_N.'_'.static::$databaseTableName;
        }