Beispiel #1
0
 public function delete_batch()
 {
     if (!$this->check_power('subject_delete')) {
         return;
     }
     $ids = (array) $this->input->post('ids');
     if ($ids) {
         $check_table = array('question', 'evaluate_group_type', 'evaluate_knowledge', 'evaluate_method_tactic', 'evaluate_rule', 'exam', 'exam_place_subject', 'exam_rule', 'exam_rule_qtype_limit', 'exam_subject_paper', 'exam_test_paper', 'group_type', 'knowledge', 'role', 'subject_category_subject', 'summary_paper_question');
         foreach ($check_table as $table) {
             if ($this->db->select("subject_id")->where_in('subject_id', $ids)->get($table)->row_array()) {
                 message('学科存在其他关联记录,不可删除!', 'admin/subject/index/');
             }
         }
         foreach ($ids as $id) {
             if ($this->db->select("subject_id")->like('subject_id_str', ",{$id},")->get('question')->row_array()) {
                 message('学科存在其他关联记录,不可删除!', 'admin/subject/index/');
             }
         }
         $this->db->where_in('subject_id', $ids)->delete('subject');
         SubjectModel::update_cache();
         //echo $this->db->last_query();
         admin_log('delete', 'subject', implode(',', $ids));
         message('学科删除成功!', 'admin/subject/index');
     } else {
         message('请选择要删除的学科');
     }
 }