Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get total number of listings? #278

Open
nom3d opened this issue Sep 26, 2020 · 1 comment
Open

How to get total number of listings? #278

nom3d opened this issue Sep 26, 2020 · 1 comment

Comments

@nom3d
Copy link

nom3d commented Sep 26, 2020

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;
	}
}
@nader14y
Copy link

Use $results->getTotalResultsCount();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants