Automattic\WooCommerce\Database\Migrations\CustomOrderTable

PostsToOrdersMigrationController::maybe_start_transaction()privateWC 1.0

Start a database transaction if the configuration mandates so.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->maybe_start_transaction(): ?bool;

Код PostsToOrdersMigrationController::maybe_start_transaction() WC 6.7.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;
}