Reputation: 35724
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.
Upvotes: 0
Views: 133
Reputation: 35724
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()>
Upvotes: 1
Reputation: 6956
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.
Upvotes: 0