You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.0 KiB

<?php
namespace Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders;
use Darksparrow\DeegraphPHP\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphPHP\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilderTrait;
#[QueryBuilderQuery]
final class Insert
{
use QueryBuilderTrait;
#[QueryBuilderRequiredField]
protected string $RelativePath = "";
protected array $Keys = [];
protected array $Schemas = [];
protected string $Values = "";
protected bool $Duplicate = false;
protected bool $Replace = false;
public function __construct()
{
}
public function __toString(): string
{
$instance = new QueryBuilderQuery();
$instance->ValidateValues($this);
$builder = "INSERT INTO $this->RelativePath";
if(sizeof($this->Keys) > 0) $builder .= "KEYS " . implode(separator: ", ", array: $this->Keys);
if(sizeof($this->Schemas) > 0) $builder .= "SCHEMAS " . implode(separator: ", ", array: $this->Schemas);
if($this->Values != "") $builder .= "VALUES $this->Values";
if($this->Duplicate) $builder .= "DUPLICATE";
if($this->Replace) $builder .= "REPLACE";
return $builder;
}
public function RelativePath(string $relativePath): Insert
{
$this->RelativePath = $relativePath;
return $this;
}
public function Keys(string $keys): Insert
{
$this->Keys = $keys;
return $this;
}
public function Schemas(string $schemas): Insert
{
$this->Schemas = $schemas;
return $this;
}
public function Values(string $values): Insert
{
$this->Values .= $values;
return $this;
}
public function Duplicate(): Insert
{
$this->Duplicate = true;
return $this;
}
public function Replace(): Insert
{
$this->Replace = true;
return $this;
}
}