I got a method to be use frequently. Here is my code:
function dashboard_notification($arr_notification_data='')
{
if($arr_notification_data == ''):
return false;
endif;
$this->db->insert('message_notification', array(
'dst_group' => MESSAGE_DESTINATION_STUDENT_SPECIFIC,
'dst_user_type' => USER_TYPE_STUDENT,
'dst_user_id' => $student_id,
'alert_type' => MESSAGE_ALERT_TYPE_EXCLAIMATION,
'dt_expiry' => date('Y-m-d H:i:s', time() + 14*24*60*60),
'src_user_type' => USER_TYPE_ADMIN,
'src_user_id' => $this->curuser['admin_id'] ? $this->curuser['admin_id'] : 0,
'msg_subject' => 'New school name',
'msg_content' => 'Your school name was rejected, please update your school name again',
'link_label' => 'Update now',
'link_url' => 'http://url/profile/update/school/',
'dt_added' => timenow(),
'dt_updated' => timenow()
));
}
Is there any better ways to make this function as a helper? Since this function got to much variables...
I would create a database adapter class, then create another class that extends it. In this case it could be called something like
StudentDatabase
and it would contain yourdashboard_notification
method.If you really wanted a helper, it would look similar to this:
Then include the class and call it like this: