Welcome Guest, Not a member yet? Register   Sign In
Why my empty array still inserts into the my db table?
#1

[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


Messages In This Thread
Why my empty array still inserts into the my db table? - by El Forum - 11-08-2012, 10:55 PM
Why my empty array still inserts into the my db table? - by El Forum - 11-08-2012, 11:15 PM
Why my empty array still inserts into the my db table? - by El Forum - 11-08-2012, 11:42 PM
Why my empty array still inserts into the my db table? - by El Forum - 11-08-2012, 11:58 PM
Why my empty array still inserts into the my db table? - by El Forum - 11-09-2012, 12:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB