WooCommerce Code Reference

SqlQuery
in package

Admin\API\Reports\SqlQuery: Common parent for manipulating SQL query clauses.

Table of Contents

$context  : string
Data store context used to pass to filters.
$sql_clauses  : array<string|int, mixed>
List of SQL clauses.
$sql_filters  : array<string|int, mixed>
SQL clause merge filters.
__construct()  : mixed
Constructor.
add_sql_clause()  : mixed
Add a SQL clause to be included when get_data is called.
clear_all_clauses()  : mixed
Reinitialize the clause array.
get_query_statement()  : string
Get the full SQL statement.
clear_sql_clause()  : mixed
Clear SQL clauses by type.
get_sql_clause()  : string
Get SQL clause by type.
str_replace_clause()  : mixed
Replace strings within SQL clauses by type.

Properties

$sql_clauses

List of SQL clauses.

private array<string|int, mixed> $sql_clauses = array('select' => array(), 'from' => array(), 'left_join' => array(), 'join' => array(), 'right_join' => array(), 'where' => array(), 'where_time' => array(), 'group_by' => array(), 'having' => array(), 'limit' => array(), 'order_by' => array(), 'union' => array())

$sql_filters

SQL clause merge filters.

private array<string|int, mixed> $sql_filters = array('where' => array('where', 'where_time'), 'join' => array('right_join', 'join', 'left_join'))

Methods

__construct()

Constructor.

public __construct([string $context = '' ]) : mixed
Parameters
$context : string = ''

Optional context passed to filters. Default empty string.

Return values
mixed

add_sql_clause()

Add a SQL clause to be included when get_data is called.

public add_sql_clause(string $type, string $clause) : mixed
Parameters
$type : string

Clause type.

$clause : string

SQL clause.

Return values
mixed

clear_sql_clause()

Clear SQL clauses by type.

protected clear_sql_clause(string|array<string|int, mixed> $types) : mixed
Parameters
$types : string|array<string|int, mixed>

Clause type.

Return values
mixed

get_sql_clause()

Get SQL clause by type.

protected get_sql_clause(string $type[, string $handling = 'unfiltered' ]) : string
Parameters
$type : string

Clause type.

$handling : string = 'unfiltered'

Whether to filter the return value (filtered|unfiltered). Default unfiltered.

Return values
stringSQL clause.

str_replace_clause()

Replace strings within SQL clauses by type.

protected str_replace_clause(string $type, string $search, string $replace) : mixed
Parameters
$type : string

Clause type.

$search : string

String to search for.

$replace : string

Replacement string.

Return values
mixed