Closed alexstandiford closed 4 years ago
Have you tried this?
$query = new Book_Query( array(
'date_created_query' => array(
'after' => 'yesterday',
),
'date_published_query' => array(
'after' => 'last tuesday',
)
) );
Ah, yep, that works. This is what I get for posting something too soon. I could have sworn it was do-able, and I was scanning the query code, and never found it. Thanks @ashleyfae!
This isn't documented in the code anywhere - the only way you can really tell that it's do-able is from this block of code:
// Possible dates
$possible_dates = $this->get_columns( array( 'date_query' => true ), 'and', 'name' );
foreach ( $possible_dates as $date ) {
$key = "{$date}_query";
$this->query_var_defaults[ $key ] = false;
}
I'm going to at least submit a PR to clarify this in the docs.
PR #68
It seems like it's only possible to filter by a single date column. If I'm correct about that, it would be nice if
Query
could accept an array of date queries instead of a single query, or something like that.Imagine you have a table,
books
with these columns:There's currently no way to query against both
date_created
anddate_published
in BerlinDB.I would expect that it would be possible to-do something like: