views:

41

answers:

2

I'm trying to use helpers to handle processes that involve multiple models. Is this okay in terms of best practices?

+1  A: 

What sort of work is being done in the helpers? A library might be a better choice.

someoneinomaha
It's a series of actions across multiple models. So first a status has to be set in ModelA, then a notification is sent out via ModelB and so on.
Shamoon
A library seems like the better approach to me then. Not sure if others would agree, but I usually think of helpers as more for utility-type functions.
someoneinomaha
Is it acceptable practice to load models in Libraries?
Shamoon
I haven't read anything that would lead me to believe it's bad practice to load models in Libraries.
someoneinomaha
A: 

The codeigniter user guide describes helpers:

Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category.

Think of them as akin to standard php functions. You can use them anywhere.

If it gives you the creeps to use helpers the way you are, consider your controllers as 'routers'. Use them to send information to a model and receive it back. Then you can send that info somewhere else, like another model. When you have all the info you need, you can use a helper or another function in the same controller to manipulate the information.

Personally, I mostly use helpers in my views to reformat or transform data.

kevtrout