manlio Posted November 9, 2014 Share Posted November 9, 2014 Hi I have simple question that I'm not able to solve on my own I retrieve data with find like this $users->find("template=user,user_region=$inputregion,include=all"); Everything works when $inputregion is a single "region" but I would like to retrieve also all regions but I don't know how to set the correct value of $inputregion. I tried with something like $inputregion = "%" or $inputregion="/%/" with no luck. Thank you Link to comment Share on other sites More sharing options...
owzim Posted November 9, 2014 Share Posted November 9, 2014 So your $inputregion can be multiple regions? If it's an array you can implode it with a pipe symbol: $inputregion = implode('|', $inputregion); // creates something like 'region1|region2|region3' So the selector looks something like this: $users->find("template=user, user_region=region1|region2|region3, include=all"); and it matches users with either of those regions 1 Link to comment Share on other sites More sharing options...
manlio Posted November 9, 2014 Author Share Posted November 9, 2014 Thank you owzim. I have learnt something more, but my case is a little different (sorry to be not enough clear). My $inputregion get single data from Url segment. So I have something like www.mysite.it/list/region1 www.mysite.it/list/region2 ecc... I would like to display users of all region using www.mysite.it/list/ Thanks Link to comment Share on other sites More sharing options...
owzim Posted November 9, 2014 Share Posted November 9, 2014 Why the not list the users without the region selector? $users->find("template=user, include=all"); Or if you want to display all users that have a region assigned (matching users with a non-empty user_region field): $users->find("template=user, user_region!='', include=all"); 1 Link to comment Share on other sites More sharing options...
manlio Posted November 9, 2014 Author Share Posted November 9, 2014 Ok I thought about that, but I didn't want to have two find queries for this purpouse and I believed I was missing the "wildcar". My php skill is really low so forgive me if I'm saying something obviously wrong. I would have to write two different queries like these, am I right? if (isset ($inputregion)) { $users->find("template=user,user_region=$inputregion,include=all"); } else { $users->find("template=user, user_region!='', include=all"); } Thanks 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