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.

Data Model Questions /

Search Results > Pagination


Reply


2 Posts   1092 Views

Avatar
Garrett

Community Member, 245 Posts

8 December 2010 at 4:24am

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

Avatar
swaiba

Forum Moderator, 1799 Posts

13 December 2010 at 4:52am

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