suntrop Posted June 24, 2014 Posted June 24, 2014 I added a field login_end to the user template, where I can set an end date until the account is valid. Only the minority of user have this field set (to a date in the past or future). Other users have an empty login_end. Now I need to select all users with an empty login_end field and those with a date in the future. But I am afraid it isn't possible with the selector engine of PW. // Won't work, because "," translates in SQL to "AND" template=user, login_end>=today, login_end= // won't work either template=user, login_end>=today| Next … I think I have to create two PageArrays – one with empty login_end and one with login_end >=today. And import the second one into the first PageArray with ->import($secondPageArray). But that wold make my code a lot more complicated, because I need this query 5 times in my module and other selector parts are based on variables. So I would be much happier if there would be a solution to get them all within one query. Hope someone can help
Soma Posted June 24, 2014 Posted June 24, 2014 https://processwire.com/talk/topic/3768-processwire-dev-branch/?p=64049 4
LostKobrakai Posted June 24, 2014 Posted June 24, 2014 Doesn't "template=user, !login_end<=today" work? 3
Jan Romero Posted June 24, 2014 Posted June 24, 2014 From what I understand, OR-groups are not needed here, since we only want to OR two values in the same field. Selecting login_end=1406930400|1416524400 works, so why doesn’t login_end=0|1416524400? 0 on its own matches empty datetime fields. The SQL error is "not unique table/alias", so that looks more like a bug. LostKobrakai’s solution is the best anyway, though. 1
suntrop Posted June 24, 2014 Author Posted June 24, 2014 https://processwire.com/talk/topic/3768-processwire-dev-branch/?p=64049 Seems I am a little bit early Thanks for the info! Doesn't "template=user, !login_end<=today" work? This looks like it is working, at least I am getting the correct amount with count() so I think it is what I have been looking for. Didn't know about the negation. I thought only != is working. Thanks to both of you!! That helped a lot Selecting login_end=1406930400|1416524400 works I need to check if it is blank or less/greater than. The less/greater is the 'problem' here I think. Anyhow, thanks for helping.
LostKobrakai Posted June 24, 2014 Posted June 24, 2014 I read the selector page quite accuratily a few days ago. http://processwire.com/api/selectors/ under "Negative operators".
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