Welcome Guest, Not a member yet? Register   Sign In
Helpers
#1

[eluser]depthcharge[/eluser]
In the course of coding a few models, To save an extra 'helper' load i have appended a few functions to the bottom of the model file to be used as helpers for the model in question.

I know this is what the helpers are there for, but is reasonable way if the functions are solely for this model?

i.e model file example
Code:
class Mymodel {

   function Mymodel()
   {
    .....

    }

   .....

}

// helper function
function helper1()
{
.....my helper

}

function helper2()
{
   .....
}
#2

[eluser]Thorpe Obazee[/eluser]
Why not use it as a method for the particular model?
#3

[eluser]depthcharge[/eluser]
Purely for making the calls from views to these few functions cleaner/smaller i decided to use a helper, then thought, only 1 or 2 functions, and seemed overhead to include another file.

i.e
Code:
<?php echo myfunction($myparams); ?>

<?php echo $this->mymodel->myfunction($myparams); ?>
#4

[eluser]Thorpe Obazee[/eluser]
I'd call a helper for better organization.
#5

[eluser]depthcharge[/eluser]
:-)




Theme © iAndrew 2016 - Forum software by © MyBB