Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » code problem: how show query result in my template

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

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

Page: 1
Go to End
Author Topic: 1341 Views
  • bebabeba
    Community Member
    192 Posts

    code problem: how show query result in my template Link to this post

    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 %>

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.