2

I can't seem to get the SearchQuery() function in phrets to return anything. I know my Resouce and Class. I also know the sysid of the field name I'm using in the query.

Here is my code

<?php @include_once('login.php'); ?>
<pre>
<?php

$rets = new PHRETS;

$rets->AddHeader("User-Agent", $rets_user_agent);
/* Connect */
$connect = $rets->Connect($rets_login_url, $rets_username, $rets_password, $rets_user_agent_password);

if($connect) {

    /*resources*/
    $resources = $rets->GetMetadataResources();
foreach ($resources as $resource) {
        echo "+ Resource {$resource['ResourceID']} described as " . $resource['Description'] . "\n";
}

    /*get classes*/
    $classes = $rets->GetMetadataClasses("Property");
foreach ($classes as $class) {
        echo "+ Class {$class['ClassName']} described as " . $class['Description'] . "\n";
}

    /*get fields*/
    $fields = $rets->GetMetadataTable("Property", 1);
print_r ($fields);

    /* Search RETS server */
$search = $rets->SearchQuery("Property",1,"(135=2013-01-01+)");
while ($listing = $rets->FetchRow($search)) {
   echo "Address: {$listing['StreetNumber']} {$listing['StreetName']}, ";
   echo "{$listing['City']}, ";
   echo "{$listing['State']} {$listing['ZipCode']} listed for ";
   echo "\$".number_format($listing['ListPrice'])."\n";
}





    $rets->FreeResult($search);
    $rets->Disconnect();
} else {
    $error = $rets->Error();
    print_r($error);
}



?>
</pre>

I used the GetMetadataResources() and GetMetadataClasses() to get the resource name and property names. I used GetMetadataTable("Property", 1) to get the sysid of the fields. I use the sysid for 'ListDate' to use in my query. I must be doing something wrong.

You can see the live page here http://miamiheatfan.com/phrets/example5.php

Thanks

Doug Steinberg
  • 1,122
  • 14
  • 32

1 Answers1

1

The second parameter in the search query is a string, not an integer. From the PHRETS specification: https://github.com/troydavisson/PHRETS/wiki/SearchQuery

Change your query from:

 $search = $rets->SearchQuery("Property",1,"(135=2013-01-01+)");

to:

$search = $rets->SearchQuery("Property","1","(135=2013-01-01+)");

If that doesn't work, try using the Standard Name of "ListDate" instead of the System Name of "135":

$search = $rets->SearchQuery("Property","1","(ListDate=2013-01-01+)");
Andrew Briggs
  • 1,329
  • 12
  • 26
  • Thanks for the replay. It turns out that my RETS server requires the county. I added this in and it works. (61=|BROWARD,DADE,OTHER,PALMBCH) – Doug Steinberg Jul 30 '13 at 23:36
  • @DougSteinberg I'm using mlxchange to get the listing in Miami, what solution you find to get only the listing that have been updated in the status field. mlxchange is driving me crazy...lol – Emilio Gort Nov 26 '13 at 02:39
  • 1
    @EmilioGort I don't think any MLS has a field which shows when a listing's status has been updated. You would need to have a way to compare the listing's old status with the listing's new status. Most people would use a database to store the MLS listings and then make RETS calls to compare the updated listing's status with the status in the database. – Andrew Briggs Dec 02 '13 at 17:48
  • for the moment I'm downloading all listing every 3 days for the last 6 months, compare with my db, get the new sysid(listing), and download the new images, after truncate the table and insert the listing...do you think there be a way to do this process more efficient? – Emilio Gort Dec 02 '13 at 20:09
  • also i'm curious in this link you can see the [Resource](http://ts.thebenamorgroup.com/miamipartners/test/metadataTypes.php),the classes has a key called `TableDate` what is their meaning – Emilio Gort Dec 02 '13 at 20:10