Peter Karunyu
unread,Jan 30, 2012, 1:27:29 AM1/30/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to codeigni...@googlegroups.com, Isaak Mogetutu
Below is my typical function in a model. Each function, upon failed execution of a query, submits a log entry, but I think the code can be made better. Other than wrapping the entire bold part in another function, how else can I do it?
function getSingleDocuments($id)
{
$sql = "SELECT id, `name`FROM documents WHERE id=$id";
$result = $this->db->query($sql);
if ($result)
{
return $result;
}
else {
$result['ErrorMessage'] = $this->db->_error_message();
$result['ErrorNumber'] = $this->db->_error_number();
$path = $this->uri->uri_string();
log_message('error', "DB Error: (".$result['ErrorNumber'].") ".$result['ErrorMessage']. ' Path: '.$path);
show_error('<p>A database error has occurred, a notification about this error has been sent to tech support.</p>');
return FALSE;
}
}
--
Regards,
Peter Karunyu
-------------------