Welcome Guest, Not a member yet? Register   Sign In
Empty is not NULL and the Active Record Update class...
#1

[eluser]edesign[/eluser]
I have a statement as such

$data['special_case1_answer'] = ($this->input->post('sc_chk_1_1')) ? $this->input->post('sc_answer_1_1') : '';

$this->db->where('ID',$this->input->post('recordID'));
$this->db->update('forms', $data);

WHERE I want the value of the array to go into the Active record update array if a check box is checked, however, when the checkbox is not checked, I would rather have a NULL value inserted into the database, right now I get an EMPTY value, which as any SQL person knows is not the same thing?

So my question is, using the statement above how can I inject a NULL value into a field using the array style UPDATE function of the active record class? Wrapping the NULL value in quotes would simply insert that value into the database, correct?
#2

[eluser]ontguy[/eluser]
Just putting null will work.

Code:
$data[’special_case1_answer’] = ($this->input->post(’sc_chk_1_1’)) ? $this->input->post(’sc_answer_1_1’) : null;




Theme © iAndrew 2016 - Forum software by © MyBB