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.

Archive /

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

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

code problem: how show query result in my template

Go to End



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();

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

$sqlQuery->from= "
$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 %>
<% control doRicerca %>
<% end_control %>
<% else %>
<p>Sorry, your search query did not return any results.</p>
<% end_if %>