[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
Meta API: WP_Meta_Query class
File Size: | 890 lines (31 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
WP_Meta_Query:: (12 methods):
__construct()
sanitize_query()
is_first_order_clause()
parse_query_vars()
get_cast_for_type()
get_sql()
get_sql_clauses()
get_sql_for_query()
get_sql_for_clause()
get_clauses()
find_compatible_table_alias()
has_or_relation()
Class: WP_Meta_Query - X-Ref
Core class used to implement meta queries for the Meta API.__construct( $meta_query = false ) X-Ref |
Constructor. param: array $meta_query { |
sanitize_query( $queries ) X-Ref |
Ensures the 'meta_query' argument passed to the class constructor is well-formed. Eliminates empty items and ensures that a 'relation' is set. param: array $queries Array of query clauses. return: array Sanitized array of query clauses. |
is_first_order_clause( $query ) X-Ref |
Determines whether a query clause is first-order. A first-order meta query clause is one that has either a 'key' or a 'value' array key. param: array $query Meta query arguments. return: bool Whether the query clause is a first-order clause. |
parse_query_vars( $qv ) X-Ref |
Constructs a meta query based on 'meta_*' query vars param: array $qv The query variables. |
get_cast_for_type( $type = '' ) X-Ref |
Returns the appropriate alias for the given meta type if applicable. param: string $type MySQL type to cast meta_value. return: string MySQL type. |
get_sql( $type, $primary_table, $primary_id_column, $context = null ) X-Ref |
Generates SQL clauses to be appended to a main query. param: string $type Type of meta. Possible values include but are not limited param: string $primary_table Database table where the object being filtered is stored (eg wp_users). param: string $primary_id_column ID column for the filtered object in $primary_table. param: object $context Optional. The main query object that corresponds to the type, for return: string[]|false { |
get_sql_clauses() X-Ref |
Generates SQL clauses to be appended to a main query. Called by the public WP_Meta_Query::get_sql(), this method is abstracted out to maintain parity with the other Query classes. return: string[] { |
get_sql_for_query( &$query, $depth = 0 ) X-Ref |
Generates SQL clauses for a single query array. If nested subqueries are found, this method recurses the tree to produce the properly nested SQL. param: array $query Query to parse (passed by reference). param: int $depth Optional. Number of tree levels deep we currently are. return: string[] { |
get_sql_for_clause( &$clause, $parent_query, $clause_key = '' ) X-Ref |
Generates SQL JOIN and WHERE clauses for a first-order query clause. "First-order" means that it's an array with a 'key' or 'value'. param: array $clause Query clause (passed by reference). param: array $parent_query Parent query array. param: string $clause_key Optional. The array key used to name the clause in the original `$meta_query` return: array { |
get_clauses() X-Ref |
Gets a flattened list of sanitized meta clauses. This array should be used for clause lookup, as when the table alias and CAST type must be determined for a value of 'orderby' corresponding to a meta clause. return: array Meta clauses. |
find_compatible_table_alias( $clause, $parent_query ) X-Ref |
Identifies an existing table alias that is compatible with the current query clause. We avoid unnecessary table joins by allowing each clause to look for an existing table alias that is compatible with the query that it needs to perform. An existing alias is compatible if (a) it is a sibling of `$clause` (ie, it's under the scope of the same relation), and (b) the combination of operator and relation between the clauses allows for a shared table join. In the case of WP_Meta_Query, this only applies to 'IN' clauses that are connected by the relation 'OR'. param: array $clause Query clause. param: array $parent_query Parent query of $clause. return: string|false Table alias if found, otherwise false. |
has_or_relation() X-Ref |
Checks whether the current query has any OR relations. In some cases, the presence of an OR relation somewhere in the query will require the use of a `DISTINCT` or `GROUP BY` keyword in the `SELECT` clause. The current method can be used in these cases to determine whether such a clause is necessary. return: bool True if the query contains any `OR` relations, otherwise false. |
Generated : Thu Nov 21 08:20:01 2024 | Cross-referenced by PHPXref |