Abstracted some parts of database interaction for parser tests, needs verification...
[lhc/web/wiklou.git] / includes / db / Database.php
index e3d3906..21049b6 100644 (file)
@@ -1990,6 +1990,21 @@ abstract class DatabaseBase {
                $this->commit();
        }
 
+       /**
+        * Creates a new table with structure copied from existing table
+        * Note that unlike most database abstraction functions, this function does not
+        * automatically append database prefix, because it works at a lower
+        * abstraction level.
+        *
+        * @param $oldName String: name of table whose structure should be copied
+        * @param $newName String: name of table to be created
+        * @param $temporary Boolean: whether the new table should be temporary
+        * @return Boolean: true if operation was successful
+        */
+       function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'Database::duplicateTableStructure' ) {
+               return $this->query( 'CREATE ' . ( $temporary ? 'TEMPORARY ' : '' ) . " TABLE $newName (LIKE $oldName)", $fname );
+       }
+
        /**
         * Return MW-style timestamp used for MySQL schema
         */