此為使用cfscript來做query的範例

此為我之前所看過的用法,貼出來跟大家分享一下^^



s = "select * from Author A, Post_Code_Area P where 1=1";

w = "";



if (isDefined("Form.SearchParam") and #Form.SearchParam# neq "") {

w = w & " and ((Name_C like '%#Form.SearchParam#%') or (Name_E like '%#Form.SearchParam#%') or (Alias_C like '%#Form.SearchParam#%') or (Alias_E like '%#Form.SearchParam#%'))";

}



w = w & " and A.Post_Code*=P.Post_Code and A.IsDisplay=1";

query = s & w;



if (isDefined("Form.Sort")) {

query = query & " order by #Form.Sort# #Desc()#";

}

//WriteOutput(query);







#PreserveSingleQuotes(query)#

狼翔月影 發表在 痞客邦 PIXNET 留言(0) 人氣()