Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Using setRange($skip, $max) to return 0 records

Featured Replies

I'm performing some find operations that I only want to get the total number of records returned for display purposes, and don't need to return any records.

I've tried using the following:

$max = 0;
$skip = 0;

$request->setRange($skip, $max) 

$result = $request->execute(); 

but this looks like it's returning all the found records, not zero records. I had assumed 0 was a valid value for $max but it appears this isn't so. Anyone have any experience with this or know a way to return zero records but still be able to call getFoundSetCount() to get the total number of found records?

You don't need to display found records, so I'm not sure I see the point... You can just perform the find and get the record count

  • Author
26 minutes ago, webko said:

You don't need to display found records, so I'm not sure I see the point... You can just perform the find and get the record count

Hi webko,

Thanks for your reply. My issue is that if I set $max to 0 then it returns all matching records in the result, which at a certain point will return a 500 server error as it's run out of memory.

Can you create a FM script that does the find, and sets a global field with Get(FoundCount)? Then you could use a newPerformScript() call in php, and then pull just the one field with a newFindAny() call.

Also... How many records are potentially being returned? On a tuned layout (i.e., with only the fields needed for the -find) I can return 10,000+ without error

Or another tack would be to create a layout with only the fields involved with the find, and query that.

Oops, that's what webko just said!

 

Edited by doughemi

  • Author
2 hours ago, webko said:

Also... How many records are potentially being returned? On a tuned layout (i.e., with only the fields needed for the -find) I can return 10,000+ without error

It's returning thousands of records potentially - it was working fine with just hundreds. I've changed the max to 1 and created special layouts for these finds and that has fixed the problem for now. I wish the API didn't return the meta data/data for all the found records until you requested them - just the number of records found and any errors etc. 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.