[eluser]mddd[/eluser]
There can be perfectly legitimate reasons for accessing the database from a helper. I agree with WanWizard on that.
But I do think that the example sunnyd shows here is 'dangerous' in that it is taking functionality you would normally put in a model, and moving it to the view layer. Now, you have multiple places dealing with 'loading archives': probably in an archive model somewhere, AND in this helper!
I think the correct way would be to simplify the helper to something like:
Code:
function display_monthly_archives()
{
$CI =& get_instance();
$CI->load->model('archive_model');
$archives = $CI->archive_model->get_archives();
return $this->load->view('monthly_archives', $archives, true);
}
If you do that, you have the advantage of being able to call the helper function from anywhere, without having to load the model beforehand. But still you are keeping the 'smarts' in the model and the 'output bits' in a view. Much more maintainable.
But, in the end, everyone has to do it the way they like. That's the bottom line for me.