I have a codeigniter query that Insert three foreign keys and 1 amount.
This is my query in the model:
public function create()
{
$insert_data = array(
'student_id' => $this->input->post('feestudentstudent'),
'schoolyear_id' => $this->input->post('feestudentschoolyear'),
'feetype_id' => $this->input->post('feestudentfeetype'),
'feestudent_amount' => $this->input->post('feestudentamount')
);
$status = $this->db->insert('tbl_feestudent', $insert_data);
}
What I want is if the following three columns inserted is the same, the student_id, schoolyear_id and feetype_id values exists in the same row it will not insert a new row and the amount will just add to the amount of the existing row.
Take Note: It's okay that student_id, and schoolyear_id is the same, what I want is if all the three including feetype_id is the same it will add the amount.