diff --git a/src/Database/Query/Modify.php b/src/Database/Query/Modify.php index 6c84496..f731461 100755 --- a/src/Database/Query/Modify.php +++ b/src/Database/Query/Modify.php @@ -16,6 +16,8 @@ class Modify private array $original = []; + private ?string $externalId = null; + private bool $autoIncrement = true; public function __construct(IConnection $connection, string $table) @@ -31,6 +33,13 @@ class Modify return $this; } + public function setExternalId($id): Modify + { + $this->externalId = $id; + + return $this; + } + public function setAutoIncrement(bool $autoIncrement = true): Modify { $this->autoIncrement = $autoIncrement; @@ -87,7 +96,9 @@ class Modify private function insert(): void { - if (!$this->autoIncrement) { + if ($this->externalId !== null) { + $this->attributes[$this->idName] = $this->externalId; + } elseif (!$this->autoIncrement) { $this->attributes[$this->idName] = $this->generateKey(); }