Jump to content

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


fmdataweb
 Share

This topic is 2347 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

This topic is 2347 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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