Class for generating SQL clauses to filter a user query by xprofile data.
since | 2.2.0 |
---|---|
package | BuddyPress |
__construct(array $xprofile_query)
since | 2.2.0 |
---|
array
{ Array of xprofile query clauses.
@type string $relation Optional. The MySQL keyword used to join the clauses of the query.
Accepts 'AND', or 'OR'. Default 'AND'.
@type array {
Optional. An array of first-order clause parameters, or another fully-formed xprofile query.
@type string|int $field XProfile field to filter by. Accepts a field name or ID.
@type string $value XProfile value to filter by.
@type string $compare MySQL operator used for comparing the $value. Accepts '=', '!=', '>',
'>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN',
'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', or 'RLIKE'. Default is 'IN'
when `$value` is an array, '=' otherwise.
@type string $type MySQL data type that the `value` column will be CAST to for comparisons.
Accepts 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL',
'SIGNED', 'TIME', or 'UNSIGNED'. Default is 'CHAR'.
}
}
get_cast_for_type(string $type = ''
) : string
since | 2.2.0 |
---|
string
MySQL type to cast value
.
string
MySQL type.get_sql(string $primary_table, string $primary_id_column) : array
since | 2.2.0 |
---|
string
Database table where the object being filtered is stored (eg wp_users).
string
ID column for the filtered object in $primary_table.
array
{
Array containing JOIN and WHERE SQL clauses to append to the main query.
@type string $join SQL fragment to append to the main JOIN clause.
@type string $where SQL fragment to append to the main WHERE clause.
}get_sql_for_clause(array $clause, array $parent_query) : array
"First-order" means that it's an array with a 'field' or 'value'.
since | 2.2.0 |
---|---|
global | wpdb $wpdb WordPress database object. |
array
Query clause.
array
Parent query array.
array
{
Array containing JOIN and WHERE SQL clauses to append to a first-order query.
@type string $join SQL fragment to append to the main JOIN clause.
@type string $where SQL fragment to append to the main WHERE clause.
}sanitize_query(array $queries) : array
Eliminates empty items and ensures that a 'relation' is set.
since | 2.2.0 |
---|
array
Array of query clauses.
array
Sanitized array of query clauses.find_compatible_table_alias(array $clause, array $parent_query) : string | boolean
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 BP_XProfile_Query, this * only applies to IN clauses that are connected by the relation OR.
since | 2.2.0 |
---|
array
Query clause.
array
Parent query of $clause.
string
boolean
Table alias if found, otherwise false.get_sql_clauses() : array
Called by the public \BP_XProfile_Query::get_sql(), this method is abstracted out to maintain parity with WP's Query classes.
since | 2.2.0 |
---|
array
{
Array containing JOIN and WHERE SQL clauses to append to the main query.
@type string $join SQL fragment to append to the main JOIN clause.
@type string $where SQL fragment to append to the main WHERE clause.
}get_sql_for_query(array $query, integer $depth = 0
) : array
If nested subqueries are found, this method recurses the tree to produce the properly nested SQL.
since | 2.2.0 |
---|
array
Query to parse. Passed by reference.
integer
Optional. Number of tree levels deep we currently are. Used to calculate indentation.
array
{
Array containing JOIN and WHERE SQL clauses to append to a single query array.
@type string $join SQL fragment to append to the main JOIN clause.
@type string $where SQL fragment to append to the main WHERE clause.
}is_first_order_clause(array $query) : boolean
A first-order query clause is one that has either a 'key' or a 'value' array key.
since | 2.2.0 |
---|
array
XProfile query arguments.
boolean
Whether the query clause is a first-order clause.$primary_id_column : string
since | 2.2.0 |
---|
$primary_table : string
since | 2.2.0 |
---|
$queries : array
array()
See \WP_XProfile_Query::__construct() for information on parameters.
since | 2.2.0 |
---|
$table_aliases : array
array()
since | 2.2.0 |
---|