0
votes

I have a cfc that works fine in tag mode:

<cfcomponent output="false">
<cffunction name=GetCases access="remote" returntype=Any returnformat=JSON>
<cfquery name="QryCases" datasource=#session.dsn# >
select id,surname,forename,died,dob,status from tbcases
</cfquery>
<cfreturn (QryCases)>
</cffunction>
</cfcomponent>

However the cfscript version fails and I just cant see why:

component
{
function any GetCases() access="remote" returntype="any"  returnformat="json"
 {

QryCases = Queryexecute("
    select id,surname,forename,died,dob,status from tbcases
        ","",{datasource=session.dsn});

return QryCases;
}
}

So both of these will work fine in ACF v2016 however only the script one works in Lucee v5. The json result is for Jquery Datatables

thanks for any pointers.

1
eturnformat instead of returnformat maybe? - Phillip Senn
Just using this opportunity to share that I don't use cfc's any longer and don't use cfquery either. I use stored procedures from regular .cfm pages and writeoutput SerializeJSON(qry). To me it's is much cleaner. - Phillip Senn
I assume you use stored procs for all your CRUD operations then. I suppose there is a strong argument for this as this is a job that is best handled by the database. Thanks for sharing - Advance Software

1 Answers

1
votes

I have now resolved this one. The 2nd Parameter to the Queryexecute can't be "" I changed it to {} And all worked just fine...

So to help others, here is the final code:

1 component
2 {
3 function any GetCases() access="remote" returntype="any"  returnformat="json"
 4 {

5 QryCases = Queryexecute("
6  select id,surname,forename,died,dob,status from tbcases
7   ", {}  ,{datasource=session.dsn});

8 return QryCases;
9 }
10 }

Note Line 7 above changed.