[eluser]towki[/eluser]
Okay so i have this function in my model
Code:
public function add($offense,$weapons,$transpo) {
$data1 = array(
'report_no' => $this->input->post('report_no'),
'reporting_unit' => $this->input->post('reporting_unit'),
'offenses_committed' => $offense,
'comission_dateAndTime' => $this->input->post('comission_dateAndTime'),
'commission_Place' => $this->input->post('commission_Place'),
'case_status' => $this->input->post('case_status'),
'weapons_used' => $weapons,
'transport_used' => $transpo,
'narrative'=>$this->input->post('narrative')
);
if (!empty($data1)){
return $this->db->insert('crime_details', $data1);
}
}
When $data1 array is empty,why it still perform inserts into my database table,so a new row will be added and only the id field which is auto incrementing has a value, and the rest is blank. I dont want this to happen,.. what i want is ,when there is no data to be inserted, then dont perform insert, dont add new empty rows in my table. Sorry for my english