First time here? Check out the FAQ!

Order By query in phRETS

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.

chaitanya's avatar
asked 2018-02-14 11:19:49 -0500
edit flag offensive 0 remove flag close merge delete


add a comment see more comments

2 Answers


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.

bwolven's avatar
answered 2018-02-14 11:47:20 -0500
edit flag offensive 0 remove flag delete link


add a comment see more comments

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.


DACO's avatar
answered 2018-08-09 08:29:01 -0500, updated 2018-08-09 09:01:12 -0500
edit flag offensive 0 remove flag delete link


add a comment see more comments

Your Answer

Login/Signup to Answer