Opened 10 years ago
Last modified 5 years ago
#29823 accepted enhancement
WP_Date_Query across tables
Reported by: | boonebgorges | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Query | Keywords: | needs-patch |
Focuses: | Cc: |
Description
The changes proposed in #29822 will make it possible to think about cross-table date queries. Things like: all posts from 2011 that have comments from 2013 or later.
Using this ticket as a placeholder for ideas regarding syntax (do we allow table names to be passed as a param? or perhaps a 'type' argument like WP_Meta_Query
has, which is then translated into table names?) and other discussion.
Change History (4)
This ticket was mentioned in IRC in #wordpress-dev by boonebgorges. View the logs.
10 years ago
Note: See
TracTickets for help on using
tickets.
A quick note that the changes in [29933] make this sorta possible. So to use my example above:
This translates to:
This ought to generate the correct WHERE clause. However, it doesn't build the JOIN clauses for you, so you'd have to do some other filtering to make it really work. Unfortunately,
WP_Date_Query::get_sql()
returns a string rather than an array of 'join' and 'where' strings like the other query classes, and we can't change that for backward compatibility. But maybe in a future version we can introduce another param toget_sql()
that will change the return value format, and we can make all core calls toget_sql()
use that param, so that this kind of use will be supported inWP_Query
andWP_Comment_Query
.