Automattic\WooCommerce\Database\Migrations\CustomOrderTable

PostsToOrdersMigrationController::maybe_start_transaction()privateWC 1.0

Start a database transaction if the configuration mandates so.

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

No Hooks.

Return

true|false|null. True if transaction started, false if transactions won't be used, null if transaction failed to start.

Usage

// private - for code of main (parent) class only
$result = $this->maybe_start_transaction(): ?bool;

Code of PostsToOrdersMigrationController::maybe_start_transaction() WC 7.1.0

private function maybe_start_transaction(): ?bool {
	if ( 'yes' !== get_option( CustomOrdersTableController::USE_DB_TRANSACTIONS_OPTION ) ) {
		return false;
	}

	$transaction_isolation_level = get_option( CustomOrdersTableController::DB_TRANSACTIONS_ISOLATION_LEVEL_OPTION, CustomOrdersTableController::DEFAULT_DB_TRANSACTIONS_ISOLATION_LEVEL );
	$this->verify_transaction_isolation_level( $transaction_isolation_level );
	$set_transaction_isolation_level_command = "SET TRANSACTION ISOLATION LEVEL $transaction_isolation_level";

	if ( ! $this->db_query( $set_transaction_isolation_level_command ) ) {
		return null;
	}

	return $this->db_query( 'START TRANSACTION' ) ? true : null;
}