Frage

I've got a set of processes I frequently do to a model that I keep redoing in the controller, and I'm wondering if there is a way to implement it through a function in the model, so that I can just call the model function pass some parameters and get the right query.

I've got a linked list, and there's a bit of repetition that I want to avoid.

War es hilfreich?

Lösung

figured it out...

in model:

<cffunction name="getCustomResults" returntype="query">
    <cfset all = findAll()>
    <!--- do stuff --->
    <cfreturn myQuery>
</cffunction>

getting the custom results

<cfset mySelection = model('myModel').getCustomResults()>

Andere Tipps

if there is a way to do implement it through a function in the model

Can you please tell what stops you from doing exactly this? Simply create CFC like /models/Foo.cfc where foo is name of your model and extend it with methods. Just don't forget to extend the Model.cfc. See this docs section. Inside the model you have this scope which holds all properties.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top