Ask Your Question

Order By query in phRETS

asked 2018-02-14 11:19:49 -0600

RETS URL : Username: CCAR_Mooveguru

I want to search data using "Order By" for ex. Order By L_ListingID Desc. Can you tell me how can I write a DMQL2 query for that in phRETS?

Thank you in advance.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-08-09 08:29:01 -0600

updated 2018-08-09 09:01:12 -0600

I asked the same question because in SQL you can, but in DMQL you cannot, as was stated. However, there is an easy method and answer for you, by using one of PHP's library of sort functions. You can sort the entire returned array by a specific KEY.

SINGLE KEY: ASC (List of Cities)

If you want to get a list of cities your MLS serves, you can sort that list alphabetically with ASORT() to sort from LOW to HIGH (or think alphabetically):


MULTIPLE-KEYS: DESC (Newest Listings First)

To order a list of properties, with multiple keys (fields), in the order of most recently listed, you sort the list with ARSORT() which is from NEWEST to OLDEST (HIGH to LOW).


MULTIPLE-KEYS: ASC (Lowest Priced Property First)

To a list of properties containing (Address, City, Asking_Price), in lowest price order, your code would be:

array_multisort($tempArray['Asking_Price'],SORT_ASC, SORT_NUMERIC,$listings);

ABOUT: tempArray

You will need to parse your array into one or more tempArrays using a FOR / EACH loop. Then use these tempArrays in yourarray_multisort() lines. I only showed an example of using a single KEY in a multi-key array.


edit flag offensive delete link more

answered 2018-02-14 11:47:20 -0600

RETS doesn't have an Order By option. Paragon RETS returns data in Key Field order. So for the property resource, it would be ordered by L_ListingID asc.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-02-14 11:19:49 -0600

Seen: 957 times

Last updated: Aug 09 '18