PHRETS
PHRETS copied to clipboard
How to get total number of listings?
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;
}
}
Use $results->getTotalResultsCount();