Tom. Posted June 13, 2016 Share Posted June 13, 2016 Hello, I'm currently using Google Geocode to get a postcode from the input. Based on that it searches for matching postcodes. As this will only use area code for example S10 from the full postcode S10 3AQ for example. So I'm using the selector ^=S10 which works great, until I need to search ^=S1 then it will return everything even S17 3AS. Is it possible to search whole words? In the documentation it says it does, however S1 is the start of the word not the whole word when it comes to S17 3AS. Thanks, Tom Link to comment Share on other sites More sharing options...
apeisa Posted June 13, 2016 Share Posted June 13, 2016 How about ^='S1 '? 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted June 13, 2016 Share Posted June 13, 2016 I think that this is intended behaviour. The documentation says "contains the exact word or phrase", but does not say they have to be separated from their surroundings by spaces or some other characters. In fact that is the commonly desired behaviour as you would like to find "orange" in "orаnges" most of the time. So i think your ^=S10 selector will still find S101. Link to comment Share on other sites More sharing options...
Tom. Posted June 14, 2016 Author Share Posted June 14, 2016 How about ^='S1 '? This still returns the same results. S10 and so on. EDIT - Got it ~='S1 ' I think that this is intended behaviour. The documentation says "contains the exact word or phrase", but does not say they have to be separated from their surroundings by spaces or some other characters. In fact that is the commonly desired behaviour as you would like to find "orange" in "orаnges" most of the time. So i think your ^=S10 selector will still find S101. Thank you for your input, however is there anyway to do this with a selector? Link to comment Share on other sites More sharing options...
Jan Romero Posted June 14, 2016 Share Posted June 14, 2016 ProcessWire trims and escapes selector values, so this doesn’t seem possible with pure PW selectors. You may try something like this… $query = wire('database')->prepare('SELECT pages_id FROM field_postcode WHERE data like concat(:areacode, " %")'); $query->bindValue(':areacode', 'A1', PDO::PARAM_STR); $pages->executeQuery($query); $results = $query->fetchAll(PDO::FETCH_COLUMN); $pages_matching_ = $pages->getById($results); 1 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