Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Below is the part of the query that isnt working. I do other filters before hand which work fine. I am trying to see if my event or a user attached to the event has a set country.
- $results = $results->filterAny(array(
- 'EventVenues.User.CountryID' => $data['CountryID'],
- 'CountryID' => $data['CountryID']
- ));
- If I remove one of the 2 array items from the above filter the event I expect returns fine. If I have both in like the code above then both events are not returned as I expect it to
- This is the SQL that is produced by my entire filter query:
- SELECT DISTINCT Event.ClassName, Event.Created, Event.LastEdited, Event.Title,
- Event.StartDateAndTime, Event.FinishDateAndTime, Event.Description,
- Event.AdmissionFee, Event.VenueName, Event.CustomCity, Event.AutoGenres,
- Event.Featured, Event.Visible, Event.Active, Event.ClassificationID,
- Event.AvatarID, Event.BannerID, Event.HeadlineArtistID, Event.MainVenueID,
- Event.CountryID, Event.StateID, Event.CityID, Event.VenueImageID,
- Event.CreatedByID, Event.ID, CASE WHEN Event.ClassName IS NOT NULL THEN
- Event.ClassName ELSE 'Event' END AS RecordClassName FROM Event INNER JOIN
- Event_EventVenues ON Event_EventVenues.EventID = Event.ID LEFT JOIN EventUser ON
- Event_EventVenues.EventUserID = EventUser.ID LEFT JOIN User ON User.ID =
- EventUser.UserID WHERE (Event.Active = '1') AND (Event.StartDateAndTime >= '2015-04-10
- 00:00:00') AND (Event.Visible = '1') AND ((User.CountryID = '2') OR (Event.CountryID =
- '2'))
- The last line of "AND ((User.CountryID = '2') OR (Event.CountryID = '2'))" is a clear OR statement but does not appear to work. I have run the above SQL directly on the database and it returns the same result. Therefore the issue is with the SQL built up by Silvertripe from what I can gather
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement