Automattic\WooCommerce\Admin\API\Reports

SqlQuery::get_sql_clause()protectedWC 1.0

Get SQL clause by type.

Метод класса: SqlQuery{}

Возвращает

Строку. SQL clause.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_sql_clause( $type, $handling );
$type(строка) (обязательный)
Clause type.
$handling(строка)
Whether to filter the return value (filtered|unfiltered).
По умолчанию: unfiltered

Код SqlQuery::get_sql_clause() WC 8.7.0

protected function get_sql_clause( $type, $handling = 'unfiltered' ) {
	if ( ! isset( $this->sql_clauses[ $type ] ) ) {
		return '';
	}

	/**
	 * Default to bypassing filters for clause retrieval internal to data stores.
	 * The filters are applied when the full SQL statement is retrieved.
	 */
	if ( 'unfiltered' === $handling ) {
		return implode( ' ', $this->sql_clauses[ $type ] );
	}

	if ( isset( $this->sql_filters[ $type ] ) ) {
		$clauses = array();
		foreach ( $this->sql_filters[ $type ] as $subset ) {
			$clauses = array_merge( $clauses, $this->sql_clauses[ $subset ] );
		}
	} else {
		$clauses = $this->sql_clauses[ $type ];
	}

	/**
	 * Filter SQL clauses by type and context.
	 *
	 * @param array  $clauses The original arguments for the request.
	 * @param string $context The data store context.
	 */
	$clauses = apply_filters( "woocommerce_analytics_clauses_{$type}", $clauses, $this->context );
	/**
	 * Filter SQL clauses by type and context.
	 *
	 * @param array  $clauses The original arguments for the request.
	 */
	$clauses = apply_filters( "woocommerce_analytics_clauses_{$type}_{$this->context}", $clauses );
	return implode( ' ', $clauses );
}