Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableFieldQuery::find_or_create_table_alias_for_clause()
Finds a common table alias that the field_query clause can use, or creates one.
Method of the class: OrdersTableFieldQuery{}
No Hooks.
Return
String
. A table alias for use in an SQL JOIN clause.
Usage
// private - for code of main (parent) class only $result = $this->find_or_create_table_alias_for_clause( $q );
- $q(array) (required)
- An atomic field_query clause.
OrdersTableFieldQuery::find_or_create_table_alias_for_clause() OrdersTableFieldQuery::find or create table alias for clause code WC 9.3.3
private function find_or_create_table_alias_for_clause( $q ) { global $wpdb; if ( ! empty( $q['alias'] ) ) { return $q['alias']; } if ( empty( $q['table'] ) || empty( $q['column'] ) ) { throw new \Exception( __( 'Missing table info for query arg.', 'woocommerce' ) ); } $join = ''; if ( isset( $q['mapping_id'] ) ) { // Re-use JOINs and aliases from OrdersTableQuery for core tables. $alias = $this->query->get_core_mapping_alias( $q['mapping_id'] ); $join = $this->query->get_core_mapping_join( $q['mapping_id'] ); } else { $alias = $q['table']; $join = ''; } if ( in_array( $alias, $this->table_aliases, true ) ) { return $alias; } $this->table_aliases[] = $alias; if ( $join ) { $this->join[ $alias ] = $join; } return $alias; }