[eluser]InsiteFX[/eluser]
Would be something like this.
Code:
/**
* You can place this in a helper or in your code.
*
* USAGE: $error = $this->show_trans_error('1');
*/
public function show_trans_error($status_code = '')
{
$trans_errors = array(
'Transaction Successful!',
'Error 01: Transaction Insert Failed!',
'Error 02: Transaction Update Failed!'
);
return $trans_errors[(int)$status_code];
}
You could add to the application/config/config.php file a switch for logging etc.
Code:
// this will allow you to either display the error message or log it to the log file.
$config['trans_logging'] = TRUE;
The check:
Code:
$trans_logging = FALSE; // This is better then using the above $config but your choice!
$error = $this->show_trans_error('0');
if ($this->db->trans_status() === FALSE)
{
if ($this->trans_logging === FALSE)
{
// display however you would like $error.
}
else
{
// save $error to log file!
$this->log_message('error', $error);
}
}
You can do your Rollback and Commit within the above.
InsiteFX