Framework CRUD vs. Dynamic SQL

Day 2 of Framework learning curve and I want to throw out this question.

Historically, I have passed arguments to a CFC function that performs a read based on a variety of conditions and created a dynamic SQL query inside my 'READ' or sometimes inside my 'get' object.

Here is an example:


<cfquery name='getFoo' datasource='#...#'>
select * from Foo where true
<cfif len(arguments.id)>
and id=<cfqueryparam... value='#arguments.id#'>
</cfif>
<cfif isdefined('arguments.activeonly')>
and isactive=<cfqueryparm... value='#argument.activeonly#')>
</cfif>
<cfif .....
and ....condition....
</cfif> <!--- you get the picture --->
</cfquery>

Can I continue to create a 'read'ish query that is fluid in nature and be able to retrieve data on a variety of conditions or... would it be better form to have different objects created and called for each different instance of needing to retrieve information?

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact HHWD