Return custom query as struct?

21 views
Skip to first unread message

Thorsten Eilers

unread,
Feb 10, 2021, 8:15:43 AM2/10/21
to CFWheels

Hi,
I have a custom query, which is needed because of multiple joins to the same model.
To edit the dataset, wheels needs a structure.
Is it possible to return the query result as structure?

public function getPSALink(required string linkID) {   
        var queryService = new query();
          queryService.setName("qryPSALink");    
        queryService.setDatasource("myDatasource");
        queryService.setSQL("
                SELECT *
               FROM mytable
");           
        var result = queryService.execute();
        return result.getResult();                       
    }

Thanks in advance.
Thorsten

Tom King

unread,
Feb 10, 2021, 8:33:20 AM2/10/21
to CFWheels
Lucee allows for setting a struct as a return type 

Not sure if you can do it via `new query()` though?
T

Brandon Shea

unread,
Feb 10, 2021, 11:17:17 AM2/10/21
to CFWheels
Ben Nadel has a gist for this, which will work with ACF if you're not on Lucee.
Reply all
Reply to author
Forward
0 new messages