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/Insert.php | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 services/app/src/Sql/Internal/Insert.php (limited to 'services/app/src/Sql/Internal/Insert.php') diff --git a/services/app/src/Sql/Internal/Insert.php b/services/app/src/Sql/Internal/Insert.php new file mode 100644 index 0000000..1bdd06f --- /dev/null +++ b/services/app/src/Sql/Internal/Insert.php @@ -0,0 +1,62 @@ + $values + */ + private ?array $values; + + /** + * @internal + */ + public function __construct( + private readonly QueryBuilder $sql, + private readonly string $table, + ) { + } + + /** + * @param array $values + */ + public function values(array $values): self + { + $this->values = $values; + return $this; + } + + /** + * @return positive-int + */ + public function execute(): int + { + return $this->sql->_executeInsert($this); + } + + /** + * @internal + */ + public function _getTable(): string + { + return $this->table; + } + + /** + * @internal + * @return array + */ + public function _getValues(): array + { + if (!isset($this->values)) { + throw new InvalidSqlException('INSERT: $values must be set before calling execute()'); + } + return $this->values; + } +} -- cgit v1.2.3-70-g09d2