我的服务器上有一个 .cfc,用于运行查询并将结果发送回 phonegap 应用程序。我无法获得正确的语法来检查查询中是否返回了任何数据并在结果中发回一个字符串,例如“未找到数据”以显示。这是我的代码...
remote array function getintList() {
var q = new com.adobe.coldfusion.query();
q.setDatasource("myData");
q.setSQL("select id1, Date, ShowLInk, IntName, description from myData Where intyear = #dateformat(Now(), "YYYY")# order by date desc");
var data = q.execute().getResult();
var result = [];
for(var i=1; i<= data.recordCount; i++) {
arrayAppend(result, {"id"=data.id1[i], "name"=data.IntName[i], "date"=dateformat(data.date[i], "mmmm d, yyyy"), "description"=data.description[i], "showlink"=data.ShowLInk[i]});
}
return result;
}
想也许我可以做一个像这样的cfif语句,但它不起作用......
<cfif data.recordcount lt 1>
result = "no data"
return result;
<cfelse>
return result;
</cfif>
希望可以有人帮帮我。