Jump to content

Matching pages by integer field fails


Fokke
 Share

Recommended Posts

Using the latest dev branch.

In template 'event' I have two integer fields, participantsMin and participantsMax. Both fields are optional.

In the search form I'm building a selector to match events by search terms. Let's say I want to find all the events that accept 20 participants, the selector will be the following:

template=event,participantsMin<=20|0,participantsMax>=20|0

If I edit the event page and set participantsMin to 10 and participantsMax to 40, the page will be matched. If I leave either one of the fields empty, the page will not be matched.

If I understood correctly, I need a logic something like this:

template=event,(participantsMin<=20|participantsMin=0),(participantsMax>=20|participantsMax=0)

Can't find the correct term for this... (either-or?)   :)

Also, got an interesting error with this selector:

template=event,participantsMin=7|0,participantsMax=7|0
Error: Exception: SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'field_participantsmin' (in /Users/Fokke/Sites/lkp/wire/core/DatabaseQuery.php line 86)

Any help will be appreciated. Thank you!

Edited by Fokke
Link to comment
Share on other sites

I think you are running into a problem of asking for >=  and then saying either/or. I think "greater" needs to be based on an absolute, or it does not make numeric sense.

So, if you are looking for an event that has at least 20 participants, then 

template=event,participantsMin>=20

Since the Max is always greater than the min, you dont need to even ask.

If you want a range, in other words between the min and the max then

template=event,participantsMin>=20, participantsMax<=30

The max must ALWAYS be greater than the min or it wont find a result, obviously.

EDIT

I am not sure whether PW uses the SQL Between at all. However, you could try attacking the filed twice (no idea if this works)

template=event,participantsMin>=20, participantsMin<=30

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...