Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableStatusUnionQuery::get_sql
Returns the rewritten SQL query, or NULL when the query is not eligible for the rewrite.
Метод класса: OrdersTableStatusUnionQuery{}
Хуков нет.
Возвращает
string|null. The rewritten SQL query, or NULL if the query is not eligible.
Использование
$OrdersTableStatusUnionQuery = new OrdersTableStatusUnionQuery(); $OrdersTableStatusUnionQuery->get_sql( $clauses, $suppress_filters ): ?string;
- $clauses(string[]) (обязательный)
- Associative array with the final
'fields','join','where','groupby','orderby'and'limits'clauses (the latter four including their keywords). - $suppress_filters(true|false) (обязательный)
- Whether the query is running with filters suppressed.
Список изменений
| С версии 11.0.0 | Введена. |
Код OrdersTableStatusUnionQuery::get_sql() OrdersTableStatusUnionQuery::get sql WC 11.2.2
public function get_sql( array $clauses, bool $suppress_filters ): ?string {
// Each step either extracts a validated piece of the rewrite or bails out (returns null) when the query
// isn't the plain "type + status, ordered by creation date" shape we can safely rewrite. The UNION is only
// assembled once every piece is in place.
if ( ! $this->has_rewritable_clause_shape( $clauses ) ) {
return null;
}
$direction = $this->extract_order_direction( $clauses['orderby'] ?? '' );
if ( null === $direction ) {
return null;
}
$limit = $this->extract_limit( $clauses['limits'] ?? '' );
if ( null === $limit ) {
return null;
}
$types_and_statuses = $this->extract_types_and_statuses();
if ( null === $types_and_statuses ) {
return null;
}
list( $types, $statuses ) = $types_and_statuses;
if ( ! $this->is_enabled( $types, $statuses, $suppress_filters ) ) {
return null;
}
if ( ! $this->where_matches_type_status_args( $clauses['where'] ?? '' ) ) {
return null;
}
list( $offset, $row_count ) = $limit;
return $this->build_union_sql( $types, $statuses, $direction, $offset + $row_count, $clauses['limits'] ?? '' );
}