| phRETS query issue phRETS query issue |
drooh

msg:4438834 | 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

msg:4438916 | 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

msg:4438926 | 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!
|
|
|