[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-xprofile/classes/ -> class-bp-xprofile-query.php (summary)

BuddyPress XProfile Classes.

File Size: 532 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

BP_XProfile_Query:: (9 methods):
  __construct()
  sanitize_query()
  is_first_order_clause()
  get_cast_for_type()
  get_sql_clauses()
  get_sql_for_query()
  get_sql()
  get_sql_for_clause()
  find_compatible_table_alias()


Class: BP_XProfile_Query  - X-Ref

Class for generating SQL clauses to filter a user query by xprofile data.

__construct( $xprofile_query )   X-Ref
Constructor.

param: array $xprofile_query {
since: 2.2.0

sanitize_query( $queries )   X-Ref
Ensure the `xprofile_query` argument passed to the class constructor is well-formed.

Eliminates empty items and ensures that a 'relation' is set.

return: array Sanitized array of query clauses.
param: array $queries Array of query clauses.
since: 2.2.0

is_first_order_clause( $query )   X-Ref
Determine whether a query clause is first-order.

A first-order query clause is one that has either a 'key' or a 'value' array key.

return: bool  Whether the query clause is a first-order clause.
param: array $query XProfile query arguments.
since: 2.2.0

get_cast_for_type( $type = '' )   X-Ref
Return the appropriate alias for the given field type if applicable.

return: string MySQL type.
param: string $type MySQL type to cast `value`.
since: 2.2.0

get_sql_clauses()   X-Ref
Generate SQL clauses to be appended to a main query.

Called by the public {@see BP_XProfile_Query::get_sql()}, this method is abstracted out to maintain parity
with WP's Query classes.

return: array {
since: 2.2.0

get_sql_for_query( &$query, $depth = 0 )   X-Ref
Generate SQL clauses for a single query array.

If nested subqueries are found, this method recurses the tree to produce the properly nested SQL.

return: array {
param: array $query Query to parse. Passed by reference.
param: int   $depth Optional. Number of tree levels deep we currently are. Used to calculate indentation.
since: 2.2.0

get_sql( $primary_table, $primary_id_column )   X-Ref
Generates SQL clauses to be appended to a main query.

return: array {
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.
since: 2.2.0

get_sql_for_clause( &$clause, $parent_query )   X-Ref
Generate SQL JOIN and WHERE clauses for a first-order query clause.

"First-order" means that it's an array with a 'field' or 'value'.

return: array {
param: array $clause       Query clause.
param: array $parent_query Parent query array.
since: 2.2.0

find_compatible_table_alias( $clause, $parent_query )   X-Ref
Identify 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 BP_XProfile_Query,
this * only applies to IN clauses that are connected by the relation OR.

return: string|bool Table alias if found, otherwise false.
param: array $clause       Query clause.
param: array $parent_query Parent query of $clause.
since: 2.2.0



Generated: Thu Nov 21 01:00:57 2024 Cross-referenced by PHPXref 0.7.1