Automattic\WooCommerce\Admin\Features\Blueprint\Importers

ImportSetWCShipping::insert()protectedWC 1.0

Insert data into the specified table.

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

Хуков нет.

Возвращает

Массив. The IDs of the inserted rows.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->insert( $table, $format, $rows );
$table(строка) (обязательный)
The table name.
$format(массив) (обязательный)
The data format.
$rows(массив) (обязательный)
The rows to insert.

Заметки

  • Global. \wpdb. $wpdb WordPress database abstraction object.

Код ImportSetWCShipping::insert() WC 9.7.1

protected function insert( $table, $format, $rows ) {
	global $wpdb;
	$inserted_ids = array();
	$table        = $wpdb->prefix . $table;
	$format       = implode( ', ', $format );
	foreach ( $rows as $row ) {
		$row     = (array) $row;
		$columns = implode( ', ', array_keys( $row ) );
		// phpcs:ignore
		$sql     = $wpdb->prepare( "REPLACE INTO $table ($columns) VALUES ($format)", $row );
		// phpcs:ignore
		$wpdb->query( $sql );
	}
	return $inserted_ids;
}