Files
Testing/tbs/wp-content/plugins/broken-link-checker/includes/transactions-manager.php
sean 0e8a8b3028
Some checks failed
deploy-testing / deploy (push) Has been cancelled
Initial testing snapshot
2026-11-17 16:15:01 -05:00

42 lines
814 B
PHP

<?php
class TransactionManager
{
private $isTransactionStarted = false;
private static $instance;
public function start()
{
global $wpdb;
if (!$this->isTransactionStarted) {
$wpdb->query('BEGIN');
$this->isTransactionStarted = true;
}
}
public function commit()
{
global $wpdb;
$this->start();
try {
$wpdb->query('COMMIT');
$this->isTransactionStarted = false;
} catch (Exception $e) {
$wpdb->query('ROLLBACK');
$this->isTransactionStarted = false;
}
}
static public function getInstance()
{
if (!self::$instance) {
self::$instance = new TransactionManager();
}
return self::$instance;
}
}