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.

Archive /

Our old forums are still available as a read-only archive.

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

code problem: how show query result in my template


Go to End


2019 Views

Avatar
bebabeba

Community Member, 193 Posts

25 November 2008 at 11:12pm

Hi guy!
I have a problem in print my query result in my template..
in Page.php I have a function ShowQueryResult taht take value from forms and put this data in my database table (X). Here I have a query that take, in te same table (X) all 'Name' record with a particular propriety. I execute query and I convert the result in silverstripe object. My problem is how to put this result to my resultPage.
This is my function:

function ShowQueryResult ($data, $form) {
$submission = new RicercaPollSubmission();
$form->saveInto($submission);
$submission->write();

$sqlQuery = new SQLQuery();
$sqlQuery->select = array(
'Name AS Name',
'PhotoID AS PhotoID'

);
$sqlQuery->from= "
DBtable
";
$sqlQuery->where = "
PhotoID(DBtable.PhotoID) = 35
";

$rawSQL = $sqlQuery->sql();
$result = $sqlQuery->execute();

$result = new DataObjectSet();
foreach($query as $row) {
$result->push(new ArrayData($row));

}

return $this->cusomise($result)->renderWith(array('SearchPage_results', 'Page'));
}

then in my SerchPage_result i put this:

<% if doRicerca %>
<ul>
<% control doRicerca %>
<li>
$result
</li>
<% end_control %>
</ul>
<% else %>
<p>Sorry, your search query did not return any results.</p>
<% end_if %>