Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::persist_db_row()privateWC 1.0

Helper method to persist a DB row to database. Uses insert_or_update when possible.

Method of the class: OrdersTableDataStore{}

No Hooks.

Returns

true|false|Int. Number of rows affected, boolean false on error.

Usage

// private - for code of main (parent) class only
$result = $this->persist_db_row( $update );
$update(array) (required)
Data containing atleast table, data and format keys, but also preferably where and where_format to use insert_or_update.

OrdersTableDataStore::persist_db_row() code WC 9.8.4

private function persist_db_row( $update ) {
	if ( isset( $update['where'] ) ) {
		$row_updated = $this->database_util->insert_or_update(
			$update['table'],
			$update['data'],
			$update['where'],
			$update['format'],
			$update['where_format']
		);
		// row_updated can be 0 when there are no changes. So we check for type as well as row count.
		$result = false !== $row_updated;
	} else {
		$result = $this->database_util->insert_on_duplicate_key_update(
			$update['table'],
			$update['data'],
			array_values( $update['format'] ),
		);
	}
	return $result;
}