public function DataAction($type = '')
 {
     if ($this->request->isPost()) {
         $Tables = json_decode($this->request->getPost('table'));
         // Export
         if ($type == 'export') {
             $path = $_SERVER['DOCUMENT_ROOT'] . APP_BACKUP;
             if (!is_dir($path)) {
                 return $this->Result('err');
             }
             // Data
             $data = '';
             foreach ($Tables as $table) {
                 $data .= "\n";
                 $data .= "#\n";
                 $data .= "# TABLE STRUCTURE FOR: " . $table . "\n";
                 $data .= "#\n\n";
                 $data .= "DROP TABLE IF EXISTS `" . $table . "`;\n";
                 $data .= "\n";
                 // DDL
                 $data .= $this->query("SHOW CREATE TABLE `" . $table . "`")[0][1] . ';';
                 $data .= "\n\n";
                 // Field
                 $Fields = $this->field($table);
                 $field = '';
                 foreach ($Fields as $val) {
                     $field .= "`" . $val . "`, ";
                 }
                 $field = substr($field, 0, -2);
                 // Data
                 $Datas = $this->query("SELECT * FROM `" . $table . "`");
                 $query = '';
                 foreach ($Datas as $val) {
                     $sql = '';
                     foreach ($val as $d) {
                         $sql .= "'" . $d . "', ";
                     }
                     $sql = substr($sql, 0, -2);
                     $query .= "INSERT INTO `" . $table . "` (" . $field . ") VALUES (" . $sql . ");\n";
                 }
                 $data .= $query;
             }
             $File = new File();
             $File->file_root = $path;
             $file = $this->request->getPost('name') . '.' . $this->request->getPost('format');
             if ($File->addFile($file, $data)) {
                 $this->response->redirect('Result/suc/SysDBRestore');
             } else {
                 $this->response->redirect('Result/err');
             }
         } elseif ($type == 'delete') {
             foreach ($Tables as $val) {
                 if ($this->db->dropTable($val) == FALSE) {
                     $this->response->redirect('Result/err');
                 }
             }
             $this->response->redirect('Result/suc/SysDBBackup');
         }
     }
 }
 function addFile($file, $fk_id, $wf_type = 'transaction')
 {
     return parent::addFile($file, $fk_id, $this->getType());
 }