Hello everybody!
I'm newbuy, so please help me.
I'm runing SS 3.1.12 with silverstripe/silverstripe-mssql module. I want to fetch data from MSSQL database and render them on page using template. My code:
class FlotPage extends Page {
};
class FlotPage_Controller extends Page_Controller {
public function ShowFlot() {
$con = DB::connect([
'type'=>'MSSQLDatabase',
'server'=>'MSSQL',
'username'=>'user',
'password'=>'12345678',
'database'=>'database'
],'MSSQL connection');
$result = DB::getConn('MSSQL connection')->query('select top 5 flo_rn,flo_nm,flo_data from flo_table');
$records = new ArrayList();
foreach($result as $row) {
$records->push(new ArrayData($row));
}
return $records;
}
}
When I open the page in browser a message appears: [User Error] Uncaught Exception: Object->__call(): the method 'fortemplate' does not exist on 'ArrayList'
I've read several posts in blog, they didn't help me.