Jump to content

PHRETS query failing


BuildMyWeb
Go to solution Solved by sKunKbad,

Recommended Posts

i am using PHRETS ( http://dangodesign.net/2013/01/getting-started-with-rets-for-php/ ) to pull data off of a MLS RETS server.  i am successfully connecting to the server so the conditional is passing.  but my queries are pulling no results.  the provider tells me DMQL2 is the database. ive only ever worked with MySQL so im in the dark. 

if($connect) 
     {
           $sixmonths = date('Y-m-d\TH:i:s', time()-15778800); // get listings updated within last 6 months
           /* Search RETS server */
           $search = $rets->SearchQuery
           (
                'Property', // Resource
                //6, // Class
                'ResidentialProperty',
                '((Lud='.$sixmonths.'+),(Status=A))', // DMQL, with SystemNames
                array(
                     'Format'   => 'COMPACT-DECODED',
                     'Select'   => 'sysid,49,112,175,9,2302,2304',
                     'Count'    => 1,
                     'Limit'    => 20
                )
           );
          
           /* If search returned results */
           if($rets->TotalRecordsFound() > 0) 
           {
                while($data = $rets->FetchRow($search)) 
                {
                     print_r($data);
                }
          
           } 
          
           else 
           { echo '0 Records Found'; }
          
           $rets->FreeResult($search);
     }
Link to comment
Share on other sites

The real problem is that although RETS tries to establish a standard, each MLS server can be configured differently. Also, if you query for something in the DMQL that doesn't belong, you'll get no feedback from the server. It's really a system designed by idiots. If you query for your resources and classes, and you've got those all mapped out, you might also be restricted by the server as to what you have access to. So, that said, all you can really do is keep trying to get some feedback until something works. I'd suggest first trying to access your listing agent's properties, because I've seen where access was restricted like that.

Link to comment
Share on other sites

You might want to play around with the following methods, just to make sure you are calling the correct class name, and searching for values that are "searchable":

 * Show the resources and classes
 */
public function show_resources_and_classes()
{
	if( $this->_connect() )
	{
		return $this->GetMetadataTypes();
	}

	return NULL;
}

// -----------------------------------------------------------------------

/**
 * Get the fields in a class
 */
public function show_class_fields( $resource_name, $class_name )
{
	if( $this->_connect() )
	{
		return $this->GetMetadataTable( $resource_name, $class_name );
	}

	return NULL;
}

// -----------------------------------------------------------------------

/**
 * Show the values that are acceptable to search a specific field by
 */
public function show_accepted_search_values( $resource_name, $field_name )
{
	if( $this->_connect() )
	{
		return $this->GetLookupValues( $resource_name, $field_name );
	}

	return NULL;
}

// -----------------------------------------------------------------------
Link to comment
Share on other sites

thank you skunk.  ive had success with the following method calls:

$types = $rets->GetMetadataTypes();

$fields = $rets->GetMetadataTable("Property", 'ResidentialProperty');

$values = $rets->GetLookupValues('Property', 'Status');

so ive got some good info.  just cant seem to put it to good use in getting search results.  i assumed it was my queries being faulty because i know there are indeed data values.  im just not accessing it for some reason.

Edited by BuildMyWeb
Link to comment
Share on other sites

So, for debugging purposes, what happens when you remove all of the conditions? For instance, if all you use for the DMQL is (Status=A), and you remove the limit, count, format, and perhaps even the select options. If you can reduce the call down to the bare minimum and it works (retrieves data) then you would want to reintroduce your options one by one until you find where the hickup is.

 

I recently created a rets class that extends phrets. You can see how I used it here:

 

https://gist.github.com/anonymous/8e678847d4bdfe75a650

Edited by sKunKbad
Link to comment
Share on other sites

i had stripped the query statement down to the following.  still no results:

$search = $rets->SearchQuery
        (
            'Property', // Resource
            //6, // Class
            'ResidentialProperty', // Class
            //'((Lud='.$sixmonths.'+),(Status=A))', // DMQL, with SystemNames
            '(Status=A)' // DMQL, with SystemNames
            //'(Status=A)', // DMQL, with SystemNames
            //array(
                //'Format'    => 'COMPACT-DECODED',
                //'Select'    => 'sysid,49,112,175,9,2302,2304',
                //'Count'    => 1,
                //'Limit'    => 20
            //)
        );
Link to comment
Share on other sites

If you are sure that Status is actually something you can use as a condition, and that A is an acceptable value, then your next step would be to contact the technical department of the organization that your contract for access is through.

 

Be sure to post the solution when you figure it out. The internet has very little information about RETS, so it's up to us to create it.

Link to comment
Share on other sites

  • Solution

I'd be willing to play with it, but I'd need access. I know these things are sensitive in nature, as the contract I signed with CRMLS was like 20 pages long. If you PM a username and password I'll give it a shot. If you don't feel comfortable doing that, I totally understand.

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.