web-base/core/Driver/SQL/Query/Delete.class.php

31 lines
710 B
PHP
Raw Normal View History

2020-04-02 00:02:51 +02:00
<?php
namespace Driver\SQL\Query;
2020-04-04 01:15:59 +02:00
use Driver\SQL\Condition\CondOr;
2021-04-02 21:58:06 +02:00
use Driver\SQL\SQL;
2020-04-04 01:15:59 +02:00
2020-04-02 00:02:51 +02:00
class Delete extends Query {
2020-04-03 17:39:58 +02:00
private string $table;
private array $conditions;
2020-04-02 00:02:51 +02:00
2021-04-02 21:58:06 +02:00
public function __construct(SQL $sql, string $table) {
2020-04-02 00:02:51 +02:00
parent::__construct($sql);
$this->table = $table;
$this->conditions = array();
}
2021-04-02 21:58:06 +02:00
public function where(...$conditions): Delete {
2020-04-04 01:15:59 +02:00
$this->conditions[] = (count($conditions) === 1 ? $conditions : new CondOr($conditions));
2020-04-02 00:02:51 +02:00
return $this;
}
public function execute() {
return $this->sql->executeDelete($this);
}
2021-04-02 21:58:06 +02:00
public function getTable(): string { return $this->table; }
public function getConditions(): array { return $this->conditions; }
2020-04-03 17:39:58 +02:00
}