I am using Coldfusion with a Fusebox framework. I am creating a survey type of application that displays one question per page using previous and next buttons to go back and forth between questions and has the ability to keep the users answers. I’m using a cfoutput to loop through my main query to get the questions, and then within that loop I need to query the answer table within that main loop. So I have at the top of my cfm page...
<cfset Question = event.GetValue("qryQuestion")>
This gets the records I need for my main loop using fusebox framework. My cfm page has a loop/output of...
<cfquery name="Answer" datasourse="DSN">
where qid = #Question.id#
My main question is how do I call the Answer query using fusebox rather than having a cfquery in my .cfm page? If I put it in my controller page it will query the answers before I need it to. Isn’t there a way to do a function call of some sort to do a nested query like this?
One solution I have is to use a cfinvoke to call the following cffuntion stored in a cfc in the model folder. This works but I still have a cfinvoke in my .cfm page and doesn’t keep with the MVC or fusebox framework we are currently using.
<cffunction name=" Answer " returntype="any">
<cfargument name="questionid" default="">
<cfquery name="getValues" datasource="DSN”>
where Answers.questionid = <cfqueryparam cfsqltype="cf_sql_integer" value="#Questionid#">
Any suggestions will be appreciated.