CodeIgniter Forums
Insert data return problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: Insert data return problem (/showthread.php?tid=78620)



Insert data return problem - wiracode - 02-16-2021

Hi, everyone
i have problem with return in insert data


Code:
$query_ins = $this->db->table('product')->insert($data);
if(!$query_ins){
return false;
}else{
return true;
}


the return value will always be true even if data fails to save

i appreciate any suggestions, thanks


RE: Insert data return problem - Zworthkey - 02-18-2021

Try this in your model:

function order_summary_insert()
$OrderLines=$this->input->post('orderlines');
$CustomerName=$this->input->post('customer');
$data = array(
'OrderLines'=>$OrderLines,
'CustomerName'=>$CustomerName
);

$this->db->insert('Customer_Orders',$data);
}