Ask Your Question
0

Order By query in phRETS

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

chaitanya gravatar image

RETS URL : http://maxebrdi.rets.fnismls.com/Rets... 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
0

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

DACO gravatar image

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

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):

asort($cities);

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).

array_multisort($tempArray['Date_Listed'],SORT_DESC,SORT_LOCALE_STRING,$listings);

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.


RESOURCES

edit flag offensive delete link more
0

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

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

Stats

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

Seen: 56 times

Last updated: Aug 09