From deacd0dfc195bca41af631114804d29937337cd8 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 17 Jan 2024 02:11:31 +0900 Subject: . --- services/app/src/Sql/Internal/Update.php | 78 ++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 services/app/src/Sql/Internal/Update.php (limited to 'services/app/src/Sql/Internal/Update.php') diff --git a/services/app/src/Sql/Internal/Update.php b/services/app/src/Sql/Internal/Update.php new file mode 100644 index 0000000..a9e9816 --- /dev/null +++ b/services/app/src/Sql/Internal/Update.php @@ -0,0 +1,78 @@ + + */ + private ?array $set; + + private string $where = ''; + + /** + * @internal + */ + public function __construct( + private readonly QueryBuilder $sql, + private readonly string $table, + ) { + } + + /** + * @param array $set + */ + public function set(array $set): self + { + $this->set = $set; + return $this; + } + + public function where(string $where): self + { + $this->where = $where; + return $this; + } + + /** + * @param array $params + */ + public function execute(array $params = []): void + { + $this->sql->_executeUpdate($this, $params); + } + + /** + * @internal + */ + public function _getTable(): string + { + return $this->table; + } + + /** + * @internal + */ + public function _getWhere(): string + { + return $this->where; + } + + /** + * @internal + * @return array + */ + public function _getSet(): array + { + if (!isset($this->set)) { + throw new InvalidSqlException('UPDATE: $set must be set before calling execute()'); + } + return $this->set; + } +} -- cgit v1.2.3-70-g09d2