无法从phrets中的SearchQuery()获得结果

时间:2013-07-30 04:35:33

标签: php rets

我似乎无法在phrets中获取SearchQuery()函数来返回任何内容。我知道我的资源和课程。我也知道我在查询中使用的字段名称的sysid。

这是我的代码

<?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>

我使用GetMetadataResources()GetMetadataClasses()来获取资源名称和属性名称。我使用GetMetadataTable("Property", 1)来获取字段的sysid。我在我的查询中使用'ListDate'的sysid。我一定是做错了。

您可以在此处查看实时页面http://miamiheatfan.com/phrets/example5.php

由于

1 个答案:

答案 0 :(得分:1)

搜索查询中的第二个参数是字符串,而不是整数。从PHRETS规范:https://github.com/troydavisson/PHRETS/wiki/SearchQuery

更改您的查询:

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

为:

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

如果不起作用,请尝试使用标准名称“ListDate”而不是系统名称“135”:

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