Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableQuery::run_queryprivateWC 1.0

Runs the SQL query.

Method of the class: OrdersTableQuery{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->run_query(): void;

OrdersTableQuery::run_query() code WC 11.0.1

private function run_query(): void {
	global $wpdb;

	// Run query.
	$this->orders = array_map( 'absint', $wpdb->get_col( $this->sql ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared

	// Set max_num_pages and found_orders if necessary.
	if ( ( $this->arg_isset( 'no_found_rows' ) && $this->args['no_found_rows'] ) || empty( $this->orders ) ) {
		return;
	}

	$offset    = (int) ( $this->limits[0] ?? 0 );
	$row_count = (int) ( $this->limits[1] ?? 0 );

	if ( $row_count > 0 || $offset > 0 ) {
		$this->found_orders  = absint( $wpdb->get_var( $this->count_sql ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
		$this->max_num_pages = $row_count > 0
			? (int) ceil( $this->found_orders / $row_count )
			: 0;
	} else {
		$this->found_orders = count( $this->orders );
	}
}