Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableDataStore::persist_db_row
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,dataandformatkeys, but also preferablywhereandwhere_formatto useinsert_or_update.
OrdersTableDataStore::persist_db_row() OrdersTableDataStore::persist db row code WC 10.7.0
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;
}