Just not getting it...how do you build a query?

1,432 views
Skip to first unread message

Rus Miller

unread,
Sep 7, 2009, 5:21:35 PM9/7/09
to PHRETS
I'm using FLEXMLS and I've copied the code from Troy's example:

$search = $phrets->SearchQuery("Property", "A", "*");

while ($property = $this->phrets->FetchRow($search)) {
$properties []= $property;
}

With this code I can get an array of all properties in the MLS. What
I'd like to do is test if they're active. For FLEXMLS, the system
name for Listing Status is LIST_105. So:

$search = $phrets->SearchQuery("Property", "A", "(LIST_105=Active)");

However, this returns an empty resource. I've seen some examples
doing something like '(LIST_105=|Active)', which also doesn't work,
nor does using the StandardName of 'ListingStatus'. What does the
pipe operator mean? Is there a resource that explains how to properly
build a query and what operators are available? What am I doing wrong?

Troy Davisson

unread,
Sep 7, 2009, 5:40:31 PM9/7/09
to phr...@googlegroups.com
Rus,

You're 95% of the way there.

Check out www.retsmd.com using the access details you have.  Once you're there, pull up A - Residential and find the LIST_15 field (LIST_105 is MLS#).  To the right will be a 'Values' link.  Click that and you'll see the possible values of that field.  Your query needs the far left value.

So:

(LIST_15=|STRINGOFCHARS)

Each property type has their own code for Active so get the others as needed.

The pipe operator designates a OR condition on a lookup field.  I started a DMQL tutorial but haven't gotten back to finish yet so maybe I can do that this next week.  In the meantime, page 56ish of the RETS 1.7.2 spec (on rets.org) outlines the syntax.

HTH,

Troy



Rus Miller

unread,
Sep 7, 2009, 6:49:53 PM9/7/09
to PHRETS
Thanks Troy,

That works but is there no way to use friendly names for the query
fields? I noticed that when I pass the option array* into the
SearchQuery method if I leave out "Format" => "COMPACT" I'll get my
results with friendly value names, like "Pittsfield" and not
"OY40LJN515S". What's the benefit of using COMPACT vs whatever other
possible values are specified?

I'm sure I could figure this out but if you or someone already knows
it would save me some time...is there a function that will look up the
friendly name and return the value so I can use it in user-driven
queries? This would be a great addition to phrets.

*Where is the option array explained? I've been looking everywhere
and can't find it. Also, an observation: FLEXMLS doesn't seem to
recognize the StandardNames option flag and returns an empty resource.

On Sep 7, 5:40 pm, "Troy Davisson" <troy.davis...@gmail.com> wrote:
> Rus,
>
> You're 95% of the way there.
>
> Check outwww.retsmd.comusing the access details you have.  Once you're there, pull up A - Residential and find the LIST_15 field (LIST_105 is MLS#).  To the right will be a 'Values' link.  Click that and you'll see the possible values of that field.  Your query needs the far left value.
>
> So:
>
> (LIST_15=|STRINGOFCHARS)
>
> Each property type has their own code for Active so get the others as needed.
>
> The pipe operator designates a OR condition on a lookup field.  I started a DMQL tutorial but haven't gotten back to finish yet so maybe I can do that this next week.  In the meantime, page 56ish of the RETS 1.7.2 spec (on rets.org) outlines the syntax.
>
> HTH,
>
> Troy
>

David Harris

unread,
Sep 7, 2009, 7:15:14 PM9/7/09
to phr...@googlegroups.com
I think its "compact-decoded" to get the resolved lookups. The "codes" are foreign keys that allow you to retain the metadata which can be easier to index, etc.

Rus Miller

unread,
Sep 7, 2009, 8:28:05 PM9/7/09
to phr...@googlegroups.com
That makes sense in that the broker can set up an enumerated list of fields (such as city names) to make entering data more accurate.   But...I hope phrets is eventually extended to make it easier to query the server without using those enumerated fields.  That would be VERY nice.

Rus Miller

unread,
Sep 8, 2009, 7:01:09 PM9/8/09
to PHRETS
I'm still having problems when customizing queries.

When using FLEXMLS, I can use these queries:

$phrets->SearchQuery("Property", "A", "*"); //returns all
$phrets->SearchQuery("Property", "A", "(LIST_39=OY40LJN515S)"); //
returns all from City=Pittsfield

But I can't do queries like these:

$phrets->SearchQuery("Property", "A", "(LIST_10=1990-01-01+)"); //
LIST_10 is ListDate...returns nothing
$phrets->SearchQuery("Property", "A", "(listing_office_name
=*inderhook*)"); //Looking for only Kinderhook offices...returns
nothing


On Sep 7, 8:28 pm, Rus Miller <lancemonot...@gmail.com> wrote:
> That makes sense in that the broker can set up an enumerated list of fields
> (such as city names) to make entering data more accurate.   But...I hope
> phrets is eventually extended to make it easier to query the server without
> using those enumerated fields.  That would be VERY nice.
>
> > > Check outwww.retsmd.comusingthe access details you have.  Once you're

Troy Davisson

unread,
Sep 9, 2009, 1:07:38 PM9/9/09
to phr...@googlegroups.com
Add the following after your SearchQuery() requests for more information about what's going on:

if ($phrets->Error()) {
   $error_info = $phrets->Error();
   echo "Error: {$error_info['type']} ({$error_info['code']}): {$error_info['text']}\n";
}

If you continue having issues with it, shoot an email over to rets-s...@flexmls.com and include your RETS username.

Rus Miller

unread,
Oct 5, 2009, 2:30:08 PM10/5/09
to PHRETS
Found a really great resource on DMQL query construction:
https://code.crt.realtors.org/svn/librets/rql/trunk/rql.html

Don't know why it's https, and the certificate is bunk, but it works
and it's really helpful.

On Sep 9, 1:07 pm, Troy Davisson <troy.davis...@gmail.com> wrote:
> Add the following after your SearchQuery() requests for more information
> about what's going on:
> if ($phrets->Error()) {
>    $error_info = $phrets->Error();
>    echo "Error: {$error_info['type']} ({$error_info['code']}):
> {$error_info['text']}\n";
>
> }
>
> If you continue having issues with it, shoot an email over to
> rets-supp...@flexmls.com and include your RETS username.
> > > > > Check outwww.retsmd.comusingtheaccess details you have.  Once you're

Troy Davisson

unread,
Oct 5, 2009, 2:38:52 PM10/5/09
to phr...@googlegroups.com
Still not complete (it's missing how to search lookup fields which was actually the reason why I started it) but it may help:

Rus Miller

unread,
Oct 5, 2009, 3:58:00 PM10/5/09
to PHRETS
Nice, thanks!
> > > > > > > Check outwww.retsmd.comusingtheaccessdetails you have.  Once

Evan Langlois

unread,
Mar 2, 2018, 5:23:00 AM3/2/18
to PHRETS
I'm just a noob here, but it looks like
(LIST_105=|15CTIZMQSUHA)

would be what you want.  Use the RETSMD site to check your MetaData and find LIST_105 and see what the value for Active is in the little "values" link for that field.  I think the "|" means that you are using one of these indirect values rather than a string.  At least, I sure hope so since that's what I'm going off of!

FYI ... neither of the two links listed above is working.  Here is one that works ... https://www.flexmls.com/developers/rets/tutorials/dmql-tutorial/


On Monday, September 7, 2009 at 3:21:35 PM UTC-6, Rus Miller wrote:
I'm using FLEXMLS and I've copied the code from Troy's example:

$search = $phrets->SearchQuery("Property", "A", "(LIST_105=Active)");

Reply all
Reply to author
Forward
0 new messages