cst989 Posted August 28, 2019 Share Posted August 28, 2019 Can anyone tell me why I get all results from the selected template on this search, only the max price (price<=999999) changes the number of results returned. Otherwise, all properties are returned despite there being lots of different values I'm sure its something really simple $pages->find("template=property,start=0,price>=0, price<=9999999, beds>=1, property_type=2,limit=3,sort=created") Link to comment Share on other sites More sharing options...
dragan Posted August 28, 2019 Share Posted August 28, 2019 What do you mean? ? If you only have this: 30 minutes ago, cst989 said: $pages->find("template=property, start=0, price>=0, beds>=1, property_type=2, limit=3, sort=created") instead of 31 minutes ago, cst989 said: $pages->find("template=property, start=0, price>=0, price<=9999999, beds>=1, property_type=2, limit=3, sort=created") Then of course you'll get much more results. Omit the limit parameter to really see how many results you'd get. But in any case, it's not logical that you get ALL properties listed (e.g. even property types 1 or 3). Care to explain a bit better? 1 Link to comment Share on other sites More sharing options...
cst989 Posted August 29, 2019 Author Share Posted August 29, 2019 Sorry yes, it's not that removing price<=99999.. changes the result, but that nothing changes the result except that Like you say, I am returning all properties, including type 1, type 3, blank type etc., when it should only be type 2. The limit isn't even working, it's returning all 10 properties. Link to comment Share on other sites More sharing options...
cst989 Posted August 29, 2019 Author Share Posted August 29, 2019 Ok so this is a bit odd, I have actually been doing this: $properties = $pages->find("$filter"); Which is not filtering results properly. However, if I echo out $filter then manually paste the result into the find instead (so it looks more like my example in the first post), it works...?? If I var_dump $filter, it's just a string... I have tried it with and without quotes Link to comment Share on other sites More sharing options...
dragan Posted August 29, 2019 Share Posted August 29, 2019 And that $filter comes from where? From a select option (thread title) value? You should try to solve this puzzle with Tracy Debugger. See what value exactly is taken from the select option and what is actually passed to find(). Perhaps you need to do something like using unformatted value, or PW is somehow doing sanitation and wipes out some characters. Just wild guesses, but maybe TD will show you what happens, and where. 1 Link to comment Share on other sites More sharing options...
alxndre Posted August 30, 2019 Share Posted August 30, 2019 Can you share your actual snippet so we can see if the issue is coming from somewhere else while you're building your filter string. 1 Link to comment Share on other sites More sharing options...
cst989 Posted August 30, 2019 Author Share Posted August 30, 2019 I worked it out while putting the code in this post and trying to remove parts til it works. I had part of my filter like this if(isset($request)) { $filter .= 'price>=".(int) $request['min'].', price<='.(int) $request['max'].', beds>='.(int) $request['beds'].', property_type='.(int) $request['property_type']; } As it turns out, you can't put line breaks in your filter like this! They obviously didn't show up in var_dump or the browser when echoed, so I missed this. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now