Search code examples
phpcodeignitercodeigniter-2

value being changed in codeigniter model function


This my function

public function update_previous_fee($id, $date, $amount) {

        $month = date("F, Y", strtotime($date));
        $this->db->where('mwf_month', $month);
        $this->db->where('mwf_student_id', $id);
        $this->db->set('mwf_pay_day', $date, FALSE);
        $this->db->set('mwf_payment', $amount, FALSE);
        $this->db->update('mwf');
}

the mwf_pay_day is being set to some garbage negative value. What I am doing wrong?


Solution

  • I have found the solution.

    changing the line

    $this->db->set('mwf_pay_day', $date, FALSE);
    

    to

    $this->db->set('mwf_pay_day', $date, TRUE);
    

    solves the problem.

    See here $this->db->set(); for details