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.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->persist_db_row( $update );
$update(массив) (обязательный)
Data containing atleast table, data and format keys, but also preferably where and where_format to use insert_or_update.

Код OrdersTableDataStore::persist_db_row() WC 9.7.1

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;
}