即使在_ _<cfquery>
queryExecute
查询
<cfquery name="qry">
SELECT * FROM tbl_products
WHERE filed1 = 1
<cfif structKeyExists(URL, "test")>
AND filed2 = 2
</cfif>
ORDER BY id DESC
</cfquery>
cf执行
<cfscript>
sql = "
SELECT * FROM tbl_products
WHERE filed1 = 1
ORDER BY id DESC
";
if (structKeyExists(URL, "test")){
sql = "
SELECT * FROM tbl_products
WHERE filed1 = 1
AND filed2 = 2
ORDER BY id DESC
";
}
qry = queryExecute(
sql = sql
);
</cfscript>
我希望我已经很好地解释了自己...