/** * Class Constructor */ public function __construct() { parent::__construct(); $this->load->model('questions_model'); $this->table_name = 'answers'; $this->pk_column = 'id'; $this->parent_column = 'id_question'; }
/** * If update goes fine then we have to delete all old answers if needed * * {@inheritDoc} * @see MY_Model::update() */ public function update($id, $data) { $question = $this->getRecordByID($id); $res = parent::update($id, $data); if ($res && $data['type'] != $question->type && $data['type'] == 'free_text') { $this->deleteAnswers($id); } return $res; }