I have a problem using Silverstripe CMS. I have basic SQL query of which results I would like to display in our front-end.i just want to use DB::query
& get the result in our front-
end. Can anyone help or please give me a hint?
public function LetestNews() {
$result[] = DB::query("SELECT t.* , (SELECT f.Name FROM File f, NewsArticle n WHERE n.ID = t.ID AND n.AttachedImageID = f.ID LIMIT 0,1) as image FROM `SiteTree` t WHERE t.ClassName LIKE '%NewsArticle%' ORDER BY t.LastEdited DESC LIMIT 0,3");
$masterLocationArray = [];
foreach( $result as $key => $data ) {
$locationArray = [];
foreach($data as $item) {
$locationArray[] = $item;
}
$masterLocationArray[$key] = $locationArray;
}
return $masterLocationArray;
}
//For the .ss template file I'm using that code <br/>
<!-- Letest News Sections -->
$LetestNews
<!-- End Latest News Sections -->