Sql server 编辑Coldfusion测量应用程序以返回一个或多个字段值
我有一个coldfusion调查应用程序,我正在尝试编辑它,以返回并比较数据库中新列的值 我在cfc文件中有以下函数,该函数应返回正在查询的新字段的值:Sql server 编辑Coldfusion测量应用程序以返回一个或多个字段值,sql-server,coldfusion,cfc,Sql Server,Coldfusion,Cfc,我有一个coldfusion调查应用程序,我正在尝试编辑它,以返回并比较数据库中新列的值 我在cfc文件中有以下函数,该函数应返回正在查询的新字段的值: <cffunction name="getQuestion" access="public" returnType="struct" output="false" hint="Grabs a question."> <cfargument name="id" type="uuid" requir
<cffunction name="getQuestion" access="public" returnType="struct" output="false"
hint="Grabs a question.">
<cfargument name="id" type="uuid" required="true" hint="The UUID of the question to get.">
<cfset var qQuestion = "">
<cfset var result = "">
<cfquery name="qQuestion" datasource="#variables.dsn#">
select #variables.tableprefix#questions.id, surveyidfk, question, questiontypeidfk, rank, required, questionfilter,
#variables.tableprefix#questiontypes.name as questiontype, #variables.tableprefix#questions.nextquestion, #variables.tableprefix#questions.nextquestionvalue
from #variables.tableprefix#questions, #variables.tableprefix#questiontypes
where #variables.tableprefix#questions.id = <cfqueryparam value="#arguments.id#" cfsqltype="CF_SQL_VARCHAR" maxlength="35">
and #variables.tableprefix#questions.questiontypeidfk = #variables.tableprefix#questiontypes.id
</cfquery>
<cfset result = variables.utils.queryToStruct(qQuestion)>
<cfset result.answers = getAnswers(arguments.id)>
<cfreturn result>
</cffunction>
我试图获取的代码
...<cfif allDone>
<cfif lastQuestion.nextQuestion neq "">
<!--- Ok, we definitely need to go someplace else. But do we have to have an answer? --->
<cfif lastQuestion.nextQuestionValue eq "">
<!--- In this branch, we ALWAYS go to another q --->
<cfset questionToLoad = application.question.getQuestion(lastQuestion.nextQuestion)>
<cfset currentInfo.currentStep = questionToLoad.rank>
<cfelse>
<cfset answer = currentInfo.answers[lastQuestion.id]>
<cfset theanswermatches = false>
<!--- first do a simple check - assumes answer is simple --->
<cfif isSimpleValue(answer) and answer is lastQuestion.nextQuestionValue>
<cfset theAnswerMatches = true>
</cfif>
<!--- next support our MC with a .list key --->
<cfif isStruct(answer) and structKeyExists(answer,"list") and listFind(answer.list, lastQuestion.nextQuestionValue)>
<cfset theAnswerMatches = true>
</cfif>
<cfif theanswermatches>
<cfset questionToLoad = application.question.getQuestion(lastQuestion.nextQuestion)>
<cfset currentInfo.currentStep = questionToLoad.rank>
<cfelse>
<cfset currentInfo.currentStep = currentInfo.currentStep + 1>
</cfif>
</cfif>
</cfif>
<cfelse>
<cfset currentInfo.currentStep = currentInfo.currentStep + 1>
</cfif>
<cflocation url="#cgi.script_name#?#cgi.query_string#" addToken="false">
</cfif>
上面的代码工作得很好,但我正在尝试添加一个条件,让它以这种方式工作。
若你们有斜体字,那个么若答案匹配,它将进入下一个问题。我想添加一个条件,其中if questionfilter=ifnot then
<cfif theanswermatches>
<cfset questionToLoad = application.question.getQuestion(lastQuestion.nextQuestion)>
<cfset currentInfo.currentStep = questionToLoad.rank>
<cfelse>
<cfset currentInfo.currentStep = currentInfo.currentStep + 1>
</cfif>
更改为
<cfif theanswermatches>
<cfset currentInfo.currentStep = currentInfo.currentStep + 1>
<cfelse>
<cfset questionToLoad = application.question.getQuestion(lastQuestion.nextQuestion)>
<cfset currentInfo.currentStep = questionToLoad.rank>
</cfif>
每次我尝试添加条件时,整个应用程序都会以调查的eithr条件结束调查。我怀疑代码没有得到questionfilter的值,我如何才能得到这个值,并确认我得到了什么
目前我做的是
<cfif lastQuestion.questionfilter eq "">
所有的建议都将受到欢迎这有很多代码需要处理,但有一件事情看起来很糟糕。在第一个函数中,您似乎引用了调用页面中的变量。谢谢Dan。它实际上是一个现有的调查应用程序。我唯一添加questionfilter来检索该列的值。我不知道我是否做得对,或者是否有更好的方法来实现这一点。原始代码没有这个field-questionfilter。