I have a .cfc on my server that I use to run a query and send the result back to a phonegap app. I cannot get the syntax right to check if any data has been returned in a query and send back a string in the result like "no data found" to display. here's my code...
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;
}
Thought maybe I could do a cfif statement like this but it doesn't work...
<cfif data.recordcount lt 1>
result = "no data"
return result;
<cfelse>
return result;
</cfif>
Hope someone can help me.