HI ORM gurus, I have a BlogPostEvent that has many EventObjects, each representing an actual event session date and time.
I'm looking for a way to select all BlogPostEvents that have at least one EventObject in the future.
At the moment I'm doing it like so:
$query = DataObject::get('BlogPostEvent') ->leftJoin('EventObject', '"EventObject"."BlogPostEventID" = "BlogPost"."ID"') ->where('EventStartDate = ( SELECT MAX(EventStartDate) FROM "EventObject" WHERE "EventObject"."BlogPostEventID" = "BlogPostEvent"."ID" AND "EventObject"."EventStartDate" > NOW() )' );
Which is working fine but doesn't feel very ORMish. Is there a nicer way of doing this?