I should be able to figure this out on my own, but I can't seem to wrap my head around how to optimize this set of logic for interpreting the existence of URL parameters.
Below is my code:
<cfif ParameterExists(start) and not ParameterExists(end) and not ParameterExists(after)>
<cfquery name="STUDENT" datasource="#STUD_DB#">
SELECT *
FROM student_profile
WHERE (Date_Modified BETWEEN '#token# #start#' AND '#token# 23:59:59')
</cfquery>
<cfelseif ParameterExists(end) and not ParameterExists(start) and not ParameterExists(after)>
<cfquery name="STUDENT" datasource="#STUD_DB#">
SELECT *
FROM student_profile
WHERE (Date_Modified BETWEEN '#token# 00:00:00' AND '#token# #end#')
</cfquery>
<cfelseif ParameterExists(start) and ParameterExists(end) and not ParameterExists(after)>
<cfquery name="STUDENT" datasource="#STUD_DB#">
SELECT *
FROM student_profile
WHERE (Date_Modified BETWEEN '#token# #start#' AND '#token# #end#')
</cfquery>
<cfelseif ParameterExists(after) and not ParameterExists(start) and not ParameterExists(end)>
<cfquery name="STUDENT" datasource="#STUD_DB#">
SELECT *
FROM student_profile
WHERE (Date_Modified BETWEEN '#token# #after#' AND '#today# 23:59:59')
</cfquery>
<cfelse>
<cfquery name="STUDENT" datasource="#STUD_DB#">
SELECT *
FROM student_profile
WHERE (Date_Modified BETWEEN '#token# 00:00:00' AND '#token# 23:59:59')
</cfquery>
Its a disgusting chunk of code, I know. Its operation is pretty simple though, run a query with a set of parameters if they exist.
I would like to have some sort of short circuit logic so I can just say
<cfif (logic to check parameters) >
<cfquery name="STUDENT" datasource="#STUD_DB#">
SELECT *
FROM student_profile
WHERE (Date_Modified BETWEEN '#startdate# #starttime#' AND '#enddate# #endtime#')
</cfquery>
This would most likely require me to set default values as well, but I am okay with that.
Any help on this?