function remove($whatID, $id) { $removedChapter = $this->get($whatID, $id); //$allOnPage = $this->getAll('page_id', $vals['page_id'] ); $allOnPage = $this->db->get_where($this->TABLE, array('sort >' => $removedChapter->sort, 'page_id' => $removedChapter->page_id))->result(); foreach ($allOnPage as $chapter) { $this->set('id', $chapter->id, 'sort', $chapter->sort - 1); } $this->load->model('MTexts', 'MTexts', TRUE); $this->MTexts->remove('name', $removedChapter->title_name); $this->MTexts->remove('name', $removedChapter->text_name); parent::remove($whatID, $id); }