Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SQL to datamodel problem


Go to End


9 Posts   1218 Views

Avatar
Eirinn

Community Member, 6 Posts

22 December 2014 at 7:53am

[]
<?php
class ComposePage extends Page {
public function getLetters() {
$sqlQuery = new SQLQuery();
$sqlQuery->from = array(
"a_letter_template"
);
/*
$result = $sqlQuery->execute();
var_dump($result->first());
*/
$result = $sqlQuery->execute();
$Letters = new ArrayList();
foreach ($result as $record){
$Letters->push(new ArrayData($record));
}
return $Letters;
}
}

class ComposePage_Controller extends Page_Controller {

}

?>

<% loop $Letters %>
    <li>$name</li>
<% end_loop %>

Having a naming convention of getFunction that's referenced by $Function is rather obscure. Especially since I could find no trace of it in the Documentation.

Anyway, problem solved.

Go to Top