0
什麼是做什麼我<cfquery>
即使在queryExecute
CFQUERY到queryExecute:如果SQL字符串中
CFQUERY
<cfquery name="qry">
SELECT * FROM tbl_products
WHERE filed1 = 1
<cfif structKeyExists(URL, "test")>
AND filed2 = 2
</cfif>
ORDER BY id DESC
</cfquery>
cfexecute
<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>
做的最好的辦法
I希望我已經解釋清楚自己...
謝謝。我認爲我是這樣做的。我希望以某種其他「更清潔」的方式解決某些「詭計」:D – Ivan