proceed further with beans
This commit is contained in:
23
Deletion.php
23
Deletion.php
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user