Advertisement
adrianstein

Silverstripe Issue

Apr 9th, 2015
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. 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.
  2.  
  3. $results = $results->filterAny(array(
  4. 'EventVenues.User.CountryID' => $data['CountryID'],
  5. 'CountryID' => $data['CountryID']
  6. ));
  7.  
  8. 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
  9.  
  10. This is the SQL that is produced by my entire filter query:
  11.  
  12. SELECT DISTINCT Event.ClassName, Event.Created, Event.LastEdited, Event.Title,
  13. Event.StartDateAndTime, Event.FinishDateAndTime, Event.Description,
  14. Event.AdmissionFee, Event.VenueName, Event.CustomCity, Event.AutoGenres,
  15. Event.Featured, Event.Visible, Event.Active, Event.ClassificationID,
  16. Event.AvatarID, Event.BannerID, Event.HeadlineArtistID, Event.MainVenueID,
  17. Event.CountryID, Event.StateID, Event.CityID, Event.VenueImageID,
  18. Event.CreatedByID, Event.ID, CASE WHEN Event.ClassName IS NOT NULL THEN
  19. Event.ClassName ELSE 'Event' END AS RecordClassName FROM Event INNER JOIN
  20. Event_EventVenues ON Event_EventVenues.EventID = Event.ID LEFT JOIN EventUser ON
  21. Event_EventVenues.EventUserID = EventUser.ID LEFT JOIN User ON User.ID =
  22. EventUser.UserID WHERE (Event.Active = '1') AND (Event.StartDateAndTime >= '2015-04-10
  23. 00:00:00') AND (Event.Visible = '1') AND ((User.CountryID = '2') OR (Event.CountryID =
  24. '2'))
  25.  
  26. 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