Follow up: So, I’ve solved my initial problem but my question remains.. Where is the API defined?
I’ve created a statement that seems to work by a mixture of looking at the examples given in the docs and a bit of trial and error.. as follows:
$results = tribe_events()->where( ‘starts_after’, ‘now’ )
->where( ‘starts_before’, ‘+2 days’ )
->order_by( ‘event_date’ )
->order( ‘ASC’ )
->all();
<rant>
I guessed at the keyword ‘starts_before’. It seemed logical as there was a ‘starts_after’ in the documented example. Are there other useful keywords? where are they defined? I also guessed ‘now’ as it seemed logical.
Why doesn’t where(‘end_date’, ‘<=’, ‘2023-02-16’) work?
Why is it order_by( ‘event_date’ ) instead of order_by( ‘start_date’ ) which would seem more logical as start_date is a field in the returned ‘Event Object’ but event_date isn’t.
When you chain where() clauses, it seems to default to a logical AND operation. What if you wanted a logical OR operation?
So many questions! I’d really love to understand this API more as it is truly elegant and nice to use.
</rant>
Plugin Support
Darian
(@d0153)
Hi @jerrystewart99
Thanks for reaching out. I apologize for the late reply.
I guessed at the keyword ‘starts_before’. It seemed logical as there was a ‘starts_after’ in the documented example. Are there other useful keywords? where are they defined? I also guessed ‘now’ as it seemed logical.
You could try the following keywords found in the-events-calendar/src/Tribe/Repositories/Event.php
line 147.
Why doesn’t where(‘end_date’, ‘<=’, ‘2023-02-16’) work?
You could try where('ends_on_or_before','2023-02-16')
For your other questions, let me check with the team and I’ll get back to you on this once I have new information.
Plugin Support
Darian
(@d0153)
Hi @jerrystewart99
Thanks for patiently waiting.
The base repository where function is defined here: https://github.com/the-events-calendar/tribe-common/blob/master/src/Tribe/Repository.php#L518
Let me know if you have further questions or concerns.
Hi @d0153 Darian,
That’s great, thanks. I can definitely work with that.