Issue
every time I use insert function in my model, the return always true, here's my code
public function insert_text($data)
{
return $this->db->table($this->table)->insert($data);
}
call code
if ($this->text->insert_text($data)) {
echo "success";
} else {
echo "failed";
}
even the execution failed (cause of same primary key already exists), code always return "success", how to fix it?
Thanks
Solution
check if inserted successfuly
if ($this->db->insert_id()) {
echo "success";
} else {
echo "failed";
}
Answered By - emppeak
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.