我传递三个整数到一个函数在CFC,像这样的:
<cfscript>
Q = TOPBIKES.GetTopBikes(127, 10, 11);
writeDump(Q);
</cfscript>
该CFC使用这些整数来运行这样的查询:
<!--- GET TOP BIKES --->
<cffunction name="GetTopBikes">
<cfargument name="FeatureID" required="true">
<cfargument name="MinWins" required="true">
<cfargument name="RecordsToReturn" required="true">
<cfscript>
LOCAL.FeatureID = ARGUMENTS.FeatureID;
LOCAL.MinWins = ARGUMENTS.MinWins;
LOCAL.RecordsToReturn = ARGUMENTS.RecordsToReturn;
</cfscript>
<!--- RUN QUERY --->
<cfquery name="Q">
SELECT TOP #LOCAL.RecordsToReturn#
B.BikeID,
B.BikeName,
BS.PCTWins
FROM Bikes B
LEFT JOIN BikeScores BS
ON B.BikeID = BS.BikeID
WHERE BS.Wins > <cfqueryparam cfsqltype="cf_sql_integer" value="#LOCAL.MinWins#">
AND B.BikeID IN ( SELECT BikeID
FROM Bikes_Features
WHERE FeatureID = <cfqueryparam cfsqltype="cf_sql_integer" value="#LOCAL.FeatureID#">
)
ORDER BY BS.PCTWins desc
</cfquery>
<cfreturn Q>
</cffunction>
问题是,我不能让cfqueryparam在SQL语句的顶部工作。
这些工作:
SELECT TOP 11
SELECT TOP #LOCAL.RecordsToReturn#
这不起作用:
SELECT TOP <cfqueryparam
cfsqltype="cf_sql_integer"
value="#LOCAL.RecordsToReturn#">
我可以,但是用其他任何地方查询。 我知道这是一个整数,并在更换FeatureID和其他地方,例如使用时的作品。
任何线索,为什么CFQUERYPARAM不处于最佳工作?