Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Search Results > Pagination

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

Page: 1
Go to End
Author Topic: 993 Views
  • Garrett
    Avatar
    Community Member
    245 Posts

    Search Results > Pagination Link to this post

    Hi,

    I have a custom search query and results page (NewsroomSearchHolder) that I've had working for a long time and it has broken in my upgrade from 2.3.6 to 2.4.3. Specifically, it seems to be the function parseQueryLimit() in /sapphire/core/model/DataObjectSet.php. I instantiate a DataObjectSet:

    $results = new DataObjectSet();

    I run my SQLQuery():

    $result = $query->execute();
    foreach($result as $sqlResult) {
    ...
    }

    And then call:

    $results->parseQueryLimit($query);

    When I comment out the parseQueryLimit() call I get all my data back (thought the paging is of course way off); if I leave the parseQueryLimit() in, I get nasty SQL errors (Duplicate column name 'ID'). I can run this exact query directly against the database, though, and get no errors. Can someone shed some light on what exactly this function does, and why, if at all, it is changing my query?

    Has anyone else had any problems with this?

    Thanks,
    Garrett

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Search Results > Pagination Link to this post

    Well it says "Use the limit from the given query to add prev/next buttons to this DataObject" on http://api.silverstripe.org/2.4/sapphire/model/DataObjectSet.html

    I am sure it will be very obvious if you opened the source and read it - code is often the best documentation.

    In order to paginate my results I follow the recipe in the documentation... http://doc.silverstripe.org/private:recipes:pagination

    hope this helps

    993 Views
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.