Hello, I'm new to SilverStripe, so I'm still finding my way.
I have a page where I want to show a brief summary of all items added to the site in the last 60 days, ordered by date. The items are comming from 2 different database tables, so I need to use the SQL UNION function.
My SQL works fine, but looking through the documentation, it appears that UNION is not supported in SilverStripe.
First question: is there a way to do this without resorting to raw SQL?
I assume the answer is no, so I tried this:
$query = 'select "Title","Description","Created" from "ItemData" union select "Title","Description","Created" from "CollectionData" order by "Created"';
$latest = DB::query($query);
but the result appears to be incompatable with <% loop %> in my template.
Second question: how can I convert the result of the query to something I can itterate over in my template?
Third question:
Is there a better way to tackle this?
Thanks for any help on this, I imagine this is a reasonably common thing to want to do, so maybe I'm just missing somethig obvious.