php-gds: OFFSETs >1000 fail to return anything

I have a page that executes a query does some stuff with the results and then refreshes while changing an URL parameter that increases the offset of the query.

I was using queries like SELECT * FROM Artists LIMIT 1 OFFSET 523 with FetchAll() but they started returning empty at 1001. I can query my admin interface with the same query SELECT * FROM Artists LIMIT 1 OFFSET 523 and get the expected result. I have also tried the same general premise with FetchPage(1).

I’m going to try to extract the cursor and pass that between pages.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Hey Guys, So here is the code after I had few email conversations with Tom. (Thanks Tom) Hope this would help someone else.

For the first time call, you would simply query, Fetchpage, and then use GetCursor. and afterwards you would use as below.

$page_results= $obj_store_ns->query(“SELECT * FROM logs where createdby=‘XXX’ ORDER BY createdon desc”); $obj_store_ns->setCursor($str_bkcursor); // Tell it to start from the end of the previous page $page_results = $obj_store_ns->fetchPage(50); // gets the first page $str_bkcursornext = $obj_store_ns->getCursor();

The callout is, you need to have the composite index in place and its’ better (at-least for me) to convert the getcursor to HexStrings and then Cache but for sure, better than offset. (particularly if you are using for Mobile Apps)

Cheers and Thanks everyone for your support.

hi to all, now after beta of php client is not supported, can i still use cursors ? the example below will work on new version ? also i don’t understand the last solution posted here, what is : $str_bkcursor ? in this part: $obj_store_ns->setCursor($str_bkcursor);

can someone give a full sample ? thanks Yaniv

b.t.w - great work Tom, thank you for this GDS library !!!

Hi there,

“Cursors” are not strings that you should set arbitrarily - they are generated by Datastore in response to getting a page of data, so you know where to pick up again for the next page.

Please also see this note regarding supplying your own LIMIT parameter and how it may cause problems https://github.com/tomwalder/php-gds#tips-for-limit-ed-fetch-operations

Would you like some “general” paging examples? I can put some together.

Tom