Migration::copyTable PHP Method

copyTable() public method

Copy table for migration
public copyTable ( $oldtable, $newtable )
$oldtable string The name of the table already inside the database
$newtable string The copy of the old table
    function copyTable($oldtable, $newtable)
    {
        global $DB;
        if (!TableExists($newtable) && TableExists($oldtable)) {
            // Try to do a flush tables if RELOAD privileges available
            // $query = "FLUSH TABLES `$oldtable`, `$newtable`";
            // $DB->query($query);
            $query = "CREATE TABLE `{$newtable}` LIKE `{$oldtable}`";
            $DB->queryOrDie($query, $this->version . " create {$newtable}");
            $query = "INSERT INTO `{$newtable}`\n                          (SELECT *\n                           FROM `{$oldtable}`)";
            $DB->queryOrDie($query, $this->version . " copy from {$oldtable} to {$newtable}");
        }
    }