Automattic\WooCommerce\Admin\Features\Blueprint\Importers
ImportSetWCShipping::insert()
Insert data into the specified table.
Method of the class: ImportSetWCShipping{}
No Hooks.
Return
Array
. The IDs of the inserted rows.
Usage
// protected - for code of main (parent) or child class $result = $this->insert( $table, $format, $rows );
- $table(string) (required)
- The table name.
- $format(array) (required)
- The data format.
- $rows(array) (required)
- The rows to insert.
Notes
- Global. \wpdb. $wpdb WordPress database abstraction object.
ImportSetWCShipping::insert() ImportSetWCShipping::insert code 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; }