proceed further with beans

This commit is contained in:
Jan-Niclas Loosen
2025-02-24 10:54:51 +01:00
parent 024e6e73cb
commit 239b81bf0e
10 changed files with 156 additions and 197 deletions

View File

@@ -9,19 +9,14 @@ class Deletion
{
use Conditionable;
protected Schema $table;
protected Schema $schema;
public function __construct(Schema $table) {
$this->table = $table;
$this->schema = $table;
}
/**
* Generates the SQL statement.
* @return string SQL query.
* @throws InvalidArgumentException
*/
public function toSql(): string {
$table = $this->table->name;
$table = $this->schema->name;
$whereClause = $this->combineConditions();
if (!$this->isConditioned())
@@ -30,11 +25,6 @@ class Deletion
return "DELETE FROM $table WHERE $whereClause";
}
/**
* Executes the DELETE query.
* @return int Number of affected rows.
* @throws Exception
*/
public function delete(): int {
global $wpdb;
$query = $this->toSql();
@@ -45,14 +35,9 @@ class Deletion
return intval($result);
}
/**
* Clears all entries from the table.
* @return int Number of affected rows.
* @throws Exception
*/
public function truncate(): int {
global $wpdb;
$table = $this->table->name;
$table = $this->schema->name;
$query = esc_sql("TRUNCATE TABLE $table");
$result = $wpdb->query($query);