|
Server : LiteSpeed System : Linux quebec.us.hostns.io 5.14.0-687.42.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 27 11:55:12 EDT 2026 x86_64 User : gazetufm ( 1431) PHP Version : 8.1.35 Disable Function : NONE Directory : /home2/gazetufm/www/wp/wp-content/plugins/wp-statistics/src/Service/Database/Operations/ | |
|
Path: //home2/gazetufm/www/wp/wp-content/plugins/wp-statistics/src/Service/Database/Operations/Drop.php
Size: 1.28 KB
Permissions: 0644
<?php
namespace WP_Statistics\Service\Database\Operations;
/**
* Handles the dropping of database tables.
*
* This class provides methods to safely execute table drop operations
* while ensuring transactional integrity.
*/
class Drop extends AbstractTableOperation
{
/**
* Execute the table drop operation.
*
* @return self
* @throws \RuntimeException
*/
public function execute()
{
try {
$this->ensureConnection();
$this->validateTableName();
$this->setFullTableName();
return $this->transactionHandler->executeInTransaction([$this, 'dropTable']);
} catch (\Exception $e) {
throw new \RuntimeException(
sprintf("Failed to drop table `%s`: %s", $this->tableName, $e->getMessage())
);
}
}
/**
* Drop table operation to be executed in transaction.
*
* @return self
* @throws \RuntimeException
*/
public function dropTable()
{
$sql = sprintf("DROP TABLE IF EXISTS `%s`", $this->fullName);
if ($this->wpdb->query($sql) === false) {
throw new \RuntimeException(
sprintf('MySQL Error: %s', $this->wpdb->last_error)
);
}
return $this;
}
}