$DataInsert = [
'id' => $Id,
'name' => $name,
'price' => $Price,
'available' => $Stock,
];
$this->db->table('services')->insert($DataInsert) //This data does not enter the database but the response is TRUE
I know there is a column with a data type that doesn't match the data I entered, but why is the response true
although this is not entered into the database?
CodePudding user response:
Try this.
$DataInsert = array(
'id' => $Id,
'name' => $name,
'price' => $Price,
'available' => $Stock,
);
$this->db->table('services')->insert($DataInsert);
if($this->db->affected_rows() > 0){
//message
}
If you insist on evaluating the insert() method use this instead.
if($this->db->table('services')->insert($DataInsert) !==FALSE){
//message
}