I have an empty input on my browse page, but whenever I have to publish to my database, it gets an error.
Pageview:
<label for="column1">COLUMN1:</label>
<input type="input" name="column1">
Model Page:
'column1' => $this->input->post('column1'),
This code will not satisfy if my input is empty. How can I send it to my database with a value of 0 instead of empty (because it will not be satisfactory).
Column1 is an integer type, so an empty value is not an integer, as I understand it. Can someone help me.
BTW I use Codeigniter and PostgreSQL
EDIT ------- MY REAL CODE
Model
public function changeNow_table2_A(){
$seq = $this->input->post('seq');
$data = array(
'tech_voc' => $this->input->post('tech_voc'),
'bacc' => $this->input->post('bacc'),
'post_bacc' => $this->input->post('post_bacc'),
'llb' => $this->input->post('llb'),
'md' => $this->input->post('md')
);
$this->db->where('seq', $seq);
$this->db->update('table2', $data);
}
I tried to change only
'bacc' => empty($this->input->post('bacc'))? 0 : $this->input->post('bacc'),
source
share