public function _deleteOne($table, $id)
 {
     $backup = new modelBackupRestore();
     $content = $backup->_backupData($id, $name, $table);
     $backup->_insertWebLog($name, 'delete', $table, $_SESSION['adminUser'], $content, $_SESSION['adminLang']);
     $sql = "DELETE FROM `{$table}` WHERE `id`='{$id}' LIMIT 1";
     $this->db->query($sql);
     return true;
 }
 public function _getSql($type, $table, $fields, $values, $id = NULL)
 {
     $backup = new modelBackupRestore();
     if ($type == 1) {
         $content = '';
         $action = 'create';
         $sql = $this->_create($table, $fields, $values);
     } elseif ($type == 2) {
         $content = $backup->_backupData($id, $name, $table);
         $action = 'update';
         $sql = $this->_update($table, $fields, $values, $id);
     } else {
         return FALSE;
     }
     if (!$this->db->query($sql)) {
         die($this->db->error);
         return FALSE;
     } else {
         if ($type == 1) {
             $id = $this->db->insert_id;
             $backup->_backupData($id, $name, $table);
         }
         $backup->_insertWebLog($name, $action, $table, $_SESSION['adminUser'], $content, $_SESSION['adminLang']);
         return $id;
     }
 }
Exemple #3
0
 public function _getSql($type, $table, $fields, $values, $id = NULL)
 {
     $backup = new modelBackupRestore();
     if ($type == 'create') {
         $content = '';
         $sql = $this->_create($table, $fields, $values);
     } elseif ($type == 'update') {
         $content = $backup->_backupData($id, $name, $table);
         $sql = $this->_update($table, $fields, $values, $id);
     } else {
         return FALSE;
     }
     if (!$this->db->query($sql)) {
         die($this->db->error);
         return FALSE;
     } else {
         if ($type == 'create') {
             $id = $this->db->insert_id;
             $backup->_backupData($id, $name, $table);
         }
         if (isset($_SESSION['adminUser'])) {
             $user = $_SESSION['adminUser'];
         } else {
             $user = '******';
         }
         if (isset($_SESSION['adminLang'])) {
             $lang = $_SESSION['adminLang'];
         } else {
             $lang = CONS_DEFAULT_LANG;
         }
         $backup->_insertWebLog($name, $type, $table, $id, $user, $content, $lang);
         return $id;
     }
 }