homepage Welcome to WebmasterWorld Guest from 54.166.84.82
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
phRETS query issue
phRETS query issue
drooh

5+ Year Member



 
Msg#: 4438832 posted 6:57 pm on Apr 9, 2012 (gmt 0)

Im using phRETS to pull mls data off a RETS server. So far I am able to connect but I am not able to execute a query. This is what I have so far and the notes I was given.


      Offset is not supported.

      The record limit is 50,000

      Use system names (numerical), and not standard names.

      Required to use the Select clause to retrieve only those fields deemed necessary for your application.

      Status is a level 1 required field and must be accompanied with a level 2 search field such as list price= 0+

      Class 4 is the primary class and you need to use Status(79) and one other level 2 field like List Price 0+ (77).


Here is my code

$rets_login_url = "#*$!#*$!X";
$rets_username = " #*$!#*$!X ";
$rets_password = " #*$!#*$!X ";
$rets_user_agent = " #*$!#*$!X ";
$rets_user_agent_password = "useragentpassword";
require_once("phrets.php");
$rets = new phRETS;
$rets->AddHeader("User-Agent", $rets_user_agent);
$rets->SetParam("offset_support", false);
$connect = $rets->Connect($rets_login_url, $rets_username, $rets_password, $rets_user_agent_password);
$search = $rets->SearchQuery("Residential","4","(79=A),(77=1000000)", array('Format' => 'COMPACT', 'QueryType' => 'DMQL'));
// get the first record returned
$listing = $rets->FetchRow($search);
// get list of fields for our loop
$fields = $rets->SearchGetFields($search);
// loop through each field in the response and pull it's value
foreach ($fields as $field) {
echo "+ {$field} value is {$listing[$field]}\n";
}

This is the error I am getting
Warning: Invalid argument supplied for foreach() in /home/beta/phrets/test.php

Any help that you could provide would be Huge, thank you so much!

 

enigma1

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4438832 posted 9:16 pm on Apr 9, 2012 (gmt 0)

You need to do some error handling and check if the SearchGetFields member function returns an array and process it accordingly.

// loop through each field in the response and pull it's value
if( !is_array($fields) ) {
echo '<br />Error: Fields is not an array<br />';
printr $fields;
exit();
}
foreach ($fields as $field) {
......

It also possible the error manifests when you call the SearchQuery member function. It should return a resource so you could check for errors there too. I don't know the framework so I cannot tell for sure but check if the SearchQuery gets the right arguments.

drooh

5+ Year Member



 
Msg#: 4438832 posted 9:34 pm on Apr 9, 2012 (gmt 0)

I just changed

$search = $rets->SearchQuery("Residential","4","(79=A),(77=1000000)", array('Format' => 'COMPACT', 'QueryType' => 'DMQL'));

to

$search = $rets->SearchQuery("Property","4","(79=A),(77=1000000)", array('Format' => 'COMPACT', 'QueryType' => 'DMQL'));

and now things are working!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved