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

37 lines
856 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;
2020-04-02 00:02:51 +02:00
class Update extends Query {
2020-04-03 17:39:58 +02:00
private array $values;
private string $table;
private array $conditions;
2020-04-02 00:02:51 +02:00
public function __construct($sql, $table) {
parent::__construct($sql);
$this->values = array();
$this->table = $table;
$this->conditions = array();
}
public function where(...$conditions) {
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 set($key, $val) {
$this->values[$key] = $val;
return $this;
}
public function execute() {
return $this->sql->executeUpdate($this);
}
public function getTable() { return $this->table; }
public function getConditions() { return $this->conditions; }
public function getValues() { return $this->values; }
2020-04-03 17:39:58 +02:00
}