XCode Warrier XCode Warrier - 1 year ago 128
PHP Question

Google DataStore PHP GDS fetchPage from record

PHP-GDS provides the following method:

$obj_store->fetchPage(10); // Gets the first 10 books

However this only works within the same connection, I'd like to use something like:

$obj_store->fetchPage(n, 10);

so I can get a set of items from separate API calls, e.g.:

api.php?page=1&items=10 // items 0-10
api.php?page=2&items=10 // items 11-20
api.php?page=3&items=10 // items 21-30

Thank you.

Tom Tom
Answer Source

I'm the author of php-gds (https://github.com/tomwalder/php-gds)

You can do exactly what you are asking, the second parameter to fetchPage() is the OFFSET.

fetchPage(10); // gets first 10

fetchPage(10, 10); // gets 11-20

fetchPage(10, 20); // gets 21-30

This can be expensive, as fetchPage(10, 5000) will scan 5,010 rows. You may be better off using cursors if your offsets are going to be large.

For more details, see here:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download