Can't get results from SearchQuery() in phrets

孤者浪人 提交于 2019-12-22 18:27:11

问题


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


回答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+)");


来源:https://stackoverflow.com/questions/17938394/cant-get-results-from-searchquery-in-phrets

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!