Automattic\WooCommerce\Admin\API\Reports
DataStore::get_ids_table
Generates a virtual table given a list of IDs.
Метод класса: DataStore{}
Хуков нет.
Возвращает
Массив.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_ids_table( $ids, $id_field, $other_values );
- $ids(массив) (обязательный)
- Array of IDs.
- $id_field(массив) (обязательный)
- Name of the ID field.
- $other_values(массив)
- Other values that must be contained in the virtual table.
По умолчанию:array()
Код DataStore::get_ids_table() DataStore::get ids table WC 11.0.1
protected function get_ids_table( $ids, $id_field, $other_values = array() ) {
global $wpdb;
$selects = array();
foreach ( $ids as $id ) {
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$new_select = $wpdb->prepare( "SELECT %s AS {$id_field}", $id );
foreach ( $other_values as $key => $value ) {
$new_select .= $wpdb->prepare( ", %s AS {$key}", $value );
}
// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
array_push( $selects, $new_select );
}
return join( ' UNION ', $selects );
}