public function handle($data) { global $case; foreach ($data as $value => $key) { if ($value != 'table') { $count = substr_count($key, '|'); if ($count > 0) { $temp = explode('|', $key); $key = ''; $length = count($temp); for ($i = 0; $i < $length; $i++) { $key .= $temp[$i] . ' '; } } $case .= $value . ' ' . $key . ','; } } //去掉最后的逗号 $case = rtrim($case, ',') . ')'; $temp = "create table {$data->table}("; $sql = $temp . $case; $record = migrate::execute($sql); if ($record == false) { echo "{$data->table}创建失败了="; } else { echo "{$data->table}创建成功了="; } unset($case); // echo $sql; }
if (!isset($this->argv[0]) || !isset($this->argv[1])) { $this->usage(); exit(1); } $this->conferencePath = $this->argv[0]; $this->importPath = $this->argv[1]; $this->options = array_slice($this->argv, 2); } /** * Print command usage information. */ function usage() { echo "OCS 1 -> OCS 2 migration tool (requires OCS >= 1.1.5 and OCS >= 2.0.1)\n" . "Use this tool to import data from an OCS 1 system into an OCS 2 system\n\n" . "Usage: {$this->scriptName} [conference_path] [ocs1_path] [options]\n" . "conference_path Conference path to create (E.g., \"ocs\")\n" . " If path already exists, all content except conference settings\n" . " will be imported into the existing conference\n" . "ocs1_path Complete local filesystem path to the OCS 1 installation\n" . " (E.g., \"/var/www/ocs\")\n" . "options importRegistrations - import registration type and registrant\n" . " data\n" . " verbose - print additional debugging information\n" . " emailUsers - Email created users with login information\n"; } /** * Execute the import command. */ function execute() { $importer = new ImportOCS1(); if ($importer->import($this->conferencePath, $this->importPath, $this->options)) { printf("Import completed\n" . "Users imported: %u\n" . "Papers imported: %u\n", $importer->userCount, $importer->paperCount); } else { printf("Import failed!\nERROR: %s\n", $importer->error()); } } } $tool = new migrate(isset($argv) ? $argv : array()); $tool->execute();