Search code examples
cfmllucee

Lucee CFML Query issue


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.


Solution

  • 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.