PHRETS icon indicating copy to clipboard operation
PHRETS copied to clipboard

How to get total number of listings?

Open nom3d opened this issue 4 years ago • 1 comments

There is a query limit of 1000 on the server. So I know I can loop this several times, however it would be nice to know the total number of listings. Is there a way to do this? I've searched google and stack overflow but not finding anything.

This is how I am doing it right now

$i = 0;
$z = 1;
$offset = 0;
while($z!=0){
	$results = $rets->Search('Property', 'Property', '(StandardStatus=|Active),(PropertyType=Residential)', ['Limit' => 1000, 'Offset' => $offset, 'Select' => 'ListingKey']);
	$z = $results->getReturnedResultsCount();
	$offset = $offset+1000;
	foreach($results as $r){
		$sql = "INSERT INTO `$mls_active_table` (`listingkey`) VALUES ('".$r['ListingKey']."')";
		mysqli_query($con,$sql);
		$i++;
	}	
	if($z!=1000){
		break;
	}
}

nom3d avatar Sep 26 '20 15:09 nom3d

Use $results->getTotalResultsCount();

nader14y avatar Feb 28 '21 15:02 nader14y