|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00018 00028 defined('MOODLE_INTERNAL') || die(); 00029 00030 class database_mover extends database_exporter { 00032 protected $importer; 00033 protected $feeback; 00034 00046 public function __construct(moodle_database $mdb_source, moodle_database $mdb_target, 00047 $check_schema = true, progress_trace $feeback = null) { 00048 if (empty($feeback)) { 00049 $this->feeback = new null_progress_trace(); 00050 } else { 00051 $this->feeback = $feeback; 00052 } 00053 if ($check_schema) { 00054 $this->feeback->output(get_string('checkingsourcetables', 'core_dbtransfer')); 00055 } 00056 parent::__construct($mdb_source, $check_schema); 00057 $this->feeback->output(get_string('creatingtargettables', 'core_dbtransfer')); 00058 $this->importer = new database_importer($mdb_target, $check_schema); 00059 } 00060 00065 public function set_transaction_mode($mode) { 00066 $this->importer->set_transaction_mode($mode); 00067 } 00068 00077 public function begin_database_export($version, $release, $timestamp, $description) { 00078 $this->feeback->output(get_string('copyingtables', 'core_dbtransfer')); 00079 $this->importer->begin_database_import($version, $timestamp, $description); 00080 } 00081 00088 public function begin_table_export(xmldb_table $table) { 00089 $this->feeback->output(get_string('copyingtable', 'core_dbtransfer', $table->getName()), 1); 00090 $this->importer->begin_table_import($table->getName(), $table->getHash()); 00091 } 00092 00101 public function export_table_data(xmldb_table $table, $data) { 00102 $this->importer->import_table_data($table->getName(), $data); 00103 } 00104 00110 public function finish_table_export(xmldb_table $table) { 00111 $this->feeback->output(get_string('done', 'core_dbtransfer', $table->getName()), 2); 00112 $this->importer->finish_table_import($table->getName()); 00113 } 00114 00119 public function finish_database_export() { 00120 $this->importer->finish_database_import(); 00121 } 00122 }