how to get the result of active record insert in CodeIgniter how to get the result of active record insert in CodeIgniter codeigniter codeigniter

how to get the result of active record insert in CodeIgniter


To not get the DB error message make sure that you have $db['default']['db_debug'] = FALSE in the file /application/config/database.php.

Then after you've preformed your (attempted) insert you can run:

$num_inserts = $this->db->affected_rows();

If the result is 0, your insert failed and you can present an error message of your own choosing.


Use these functions

$errNo   = $this->db->_error_number();$errMess = $this->db->_error_message();

They will help