How to test if Ci successfully inserted data
You can use $this->db->affected_rows()
function of codeigniter.
See more information here
You can do something like this:
return ($this->db->affected_rows() != 1) ? false : true;
You can also do it using Transactions like this:
$this->db->trans_start();
$this->db->query("INSERT IGNORE INTO wallPosts (entryData, entryCreationDateTime, wpChurchId)
VALUES('$entryData', NOW(), '$myChurchId')");
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE) {
return "Query Failed";
} else {
// do whatever you want to do on query success
}
Here's more info on Transactions in CodeIgniter!
if you are using bootstrap on codeigniter try flash message or simply redirect
$added = $this->your_modal->function_reference($data);
if ($added) {
$this->session->set_flashdata('success', 'Added successfully.');
redirect('home');
} else {
$this->session->set_flashdata('error', 'Something wrong.');
redirect('home');
ON CONTROLLER