Cerys
4 weeks ago
16 changed files with 488 additions and 301 deletions
@ -0,0 +1,26 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\InsertQuery; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
|
|
||||
|
#[QueryBuilderQuery] |
||||
|
final class InsertQuery |
||||
|
{ |
||||
|
public string $QueryString; |
||||
|
|
||||
|
public function __construct(InsertQueryBuilder $queryBuilder) |
||||
|
{ |
||||
|
$instance = new QueryBuilderQuery(); |
||||
|
$instance->ValidateValues($queryBuilder); |
||||
|
|
||||
|
$builder = "INSERT INTO $queryBuilder->RelativePath"; |
||||
|
|
||||
|
if(sizeof($queryBuilder->Keys) > 0) $builder .= "KEYS " . implode(separator: ", ", array: $queryBuilder->Keys); |
||||
|
if(sizeof($queryBuilder->Schemas) > 0) $builder .= "SCHEMAS " . implode(separator: ", ", array: $queryBuilder->Schemas); |
||||
|
if($queryBuilder->Values != "") $builder .= "VALUES $queryBuilder->Values"; |
||||
|
if($queryBuilder->Duplicate) $builder .= "DUPLICATE"; |
||||
|
if($queryBuilder->Replace) $builder .= "REPLACE"; |
||||
|
|
||||
|
} |
||||
|
} |
@ -1,84 +1,89 @@ |
|||||
<?php |
<?php |
||||
|
|
||||
namespace Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders; |
namespace Darksparrow\DeegraphInteractions\QueryBuilder\InsertQuery; |
||||
|
|
||||
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
|
||||
#[QueryBuilderQuery] |
#[QueryBuilderQuery] |
||||
final class InsertQuery |
final class InsertQueryBuilder implements InsertQueryBuilderInterface |
||||
{ |
{ |
||||
use QueryBuilderTrait; |
use QueryBuilderTrait; |
||||
|
|
||||
#[QueryBuilderRequiredField] |
#[QueryBuilderRequiredField] |
||||
protected string $RelativePath = ""; |
protected string $RelativePath = ""; |
||||
|
|
||||
protected array $Keys = []; |
protected array $Keys = []; |
||||
|
|
||||
protected array $Schemas = []; |
protected array $Schemas = []; |
||||
|
|
||||
protected string $Values = ""; |
protected string $Values = ""; |
||||
|
|
||||
protected bool $Duplicate = false; |
protected bool $Duplicate = false; |
||||
|
|
||||
protected bool $Replace = false; |
protected bool $Replace = false; |
||||
|
|
||||
|
|
||||
public function __construct() |
public function __construct() |
||||
{ |
{ |
||||
} |
} |
||||
|
|
||||
public function __toString(): string |
public function __toString(): string |
||||
{ |
{ |
||||
$instance = new QueryBuilderQuery(); |
|
||||
$instance->ValidateValues($this); |
} |
||||
|
|
||||
$builder = "INSERT INTO $this->RelativePath"; |
public function RelativePath(string $relativePath): InsertQueryBuilder |
||||
|
{ |
||||
if(sizeof($this->Keys) > 0) $builder .= "KEYS " . implode(separator: ", ", array: $this->Keys); |
self::ValidateDeegraphPath(target: $relativePath); |
||||
if(sizeof($this->Schemas) > 0) $builder .= "SCHEMAS " . implode(separator: ", ", array: $this->Schemas); |
$this->RelativePath = $relativePath; |
||||
if($this->Values != "") $builder .= "VALUES $this->Values"; |
return $this; |
||||
if($this->Duplicate) $builder .= "DUPLICATE"; |
} |
||||
if($this->Replace) $builder .= "REPLACE"; |
|
||||
|
public function Keys(string $keys): InsertQueryBuilder |
||||
return $builder; |
{ |
||||
} |
$this->Keys = $keys; |
||||
|
return $this; |
||||
public function RelativePath(string $relativePath): InsertQuery |
} |
||||
{ |
|
||||
self::ValidateDeegraphPath(target: $relativePath); |
public function Schemas(string $schemas): InsertQueryBuilder |
||||
$this->RelativePath = $relativePath; |
{ |
||||
return $this; |
$this->Schemas = $schemas; |
||||
} |
return $this; |
||||
|
} |
||||
public function Keys(string $keys): InsertQuery |
|
||||
{ |
public function Values(string $values): InsertQueryBuilder |
||||
$this->Keys = $keys; |
{ |
||||
return $this; |
$this->Values .= $values; |
||||
} |
return $this; |
||||
|
} |
||||
public function Schemas(string $schemas): InsertQuery |
|
||||
{ |
public function Duplicate(): InsertQueryBuilder |
||||
$this->Schemas = $schemas; |
{ |
||||
return $this; |
$this->Duplicate = true; |
||||
} |
return $this; |
||||
|
} |
||||
public function Values(string $values): InsertQuery |
|
||||
{ |
public function Replace(): InsertQueryBuilder |
||||
$this->Values .= $values; |
{ |
||||
return $this; |
$this->Replace = true; |
||||
} |
return $this; |
||||
|
} |
||||
public function Duplicate(): InsertQuery |
|
||||
{ |
public function Build(): InsertQuery |
||||
$this->Duplicate = true; |
{ |
||||
return $this; |
$instance = new QueryBuilderQuery(); |
||||
} |
$instance->ValidateValues($this); |
||||
|
|
||||
public function Replace(): InsertQuery |
$builder = "INSERT INTO $this->RelativePath"; |
||||
{ |
|
||||
$this->Replace = true; |
if(sizeof($this->Keys) > 0) $builder .= "KEYS " . implode(separator: ", ", array: $this->Keys); |
||||
return $this; |
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; |
||||
|
} |
||||
} |
} |
@ -0,0 +1,8 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\InsertQuery; |
||||
|
|
||||
|
interface InsertQueryBuilderInterface |
||||
|
{ |
||||
|
public function Build() : InsertQuery; |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\PermissionsQuery; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Core\DeegraphServer; |
||||
|
|
||||
|
class PermissionQuery |
||||
|
{ |
||||
|
protected string $QueryString; |
||||
|
|
||||
|
public function __construct(string $queryString) |
||||
|
{ |
||||
|
$this->QueryString = $queryString; |
||||
|
} |
||||
|
|
||||
|
public function RunQuery(DeegraphServer $server): PermissionQueryResponse |
||||
|
{ |
||||
|
$response = $server->RunRawRequest( |
||||
|
endpoint: "/api/v1/@query", |
||||
|
method: "POST", |
||||
|
body: $this->QueryString |
||||
|
); |
||||
|
$temp = json_decode($response, true); |
||||
|
return new PermissionQueryResponse($temp); |
||||
|
} |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\PermissionsQuery; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderQuery] |
||||
|
class PermissionQueryBuilder |
||||
|
{ |
||||
|
|
||||
|
use QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderRequiredField] |
||||
|
protected string $On = ""; |
||||
|
|
||||
|
|
||||
|
#[QueryBuilderRequiredField] |
||||
|
protected string $As = ""; |
||||
|
|
||||
|
|
||||
|
public function On(string $relativePath): PermissionQueryBuilder |
||||
|
{ |
||||
|
// self::ValidateDeegraphPath(target: $relativePath); |
||||
|
$this->On = $relativePath; |
||||
|
return $this; |
||||
|
} |
||||
|
public function As(string $relativePath): PermissionQueryBuilder |
||||
|
{ |
||||
|
// self::ValidateDeegraphPath(target: $relativePath); |
||||
|
$this->As = $relativePath; |
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function Build(): PermissionQuery |
||||
|
{ |
||||
|
$builder = "PERMISSIONS "; |
||||
|
if($this->On != "") $builder .= " ON {". $this->On . "}"; |
||||
|
if($this->As != "") $builder .= " AS {". $this->As . "}"; |
||||
|
|
||||
|
return new PermissionQuery(queryString: $builder); |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\PermissionsQuery; |
||||
|
|
||||
|
interface PermissionQueryBuilderInterface |
||||
|
{ |
||||
|
public function Build() : PermissionQuery; |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\PermissionsQuery; |
||||
|
|
||||
|
class PermissionQueryResponse |
||||
|
{ |
||||
|
public bool $CanAct = false; |
||||
|
public bool $CanDelete = false; |
||||
|
public bool $CanRead = false; |
||||
|
public bool $CanWrite = false; |
||||
|
|
||||
|
public function __construct(array $deegraphResponse) |
||||
|
{ |
||||
|
foreach ($deegraphResponse["@permissions"] as $permission) |
||||
|
{ |
||||
|
switch($permission) |
||||
|
{ |
||||
|
case "ACT": |
||||
|
$this->CanAct = true; |
||||
|
break; |
||||
|
case "DELETE": |
||||
|
$this->CanDelete = true; |
||||
|
break; |
||||
|
case "READ": |
||||
|
$this->CanRead = true; |
||||
|
break; |
||||
|
case "WRITE": |
||||
|
$this->CanWrite = true; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -1,113 +1,113 @@ |
|||||
<?php |
<?php |
||||
|
|
||||
namespace Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders; |
namespace Darksparrow\DeegraphInteractions\QueryBuilder\PutQuery; |
||||
|
|
||||
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderConflictingFieldAlreadyExistsException; |
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderConflictingFieldAlreadyExistsException; |
||||
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderInvalidInputException; |
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderInvalidInputException; |
||||
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderRequiredFieldIsNotSetException; |
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderRequiredFieldIsNotSetException; |
||||
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
|
||||
final class PutQuery |
final class PutQueryBuilder |
||||
{ |
{ |
||||
use QueryBuilderTrait; |
use QueryBuilderTrait; |
||||
|
|
||||
protected string $PutWhat = ""; |
protected string $PutWhat = ""; |
||||
protected string $PutAt = ""; |
protected string $PutAt = ""; |
||||
protected string $PutInto = ""; |
protected string $PutInto = ""; |
||||
protected bool $Safe = false; |
protected bool $Safe = false; |
||||
|
|
||||
|
|
||||
public function __construct() |
public function __construct() |
||||
{ |
{ |
||||
} |
} |
||||
|
|
||||
/** |
/** |
||||
* @throws QueryBuilderRequiredFieldIsNotSetException |
* @throws QueryBuilderRequiredFieldIsNotSetException |
||||
*/ |
*/ |
||||
public function __toString(): string |
public function __toString(): string |
||||
{ |
{ |
||||
$builder = "PUT"; |
$builder = "PUT"; |
||||
if($this->PutWhat != "") $builder .= " $this->PutWhat"; |
if($this->PutWhat != "") $builder .= " $this->PutWhat"; |
||||
|
|
||||
if($this->PutAt != "") $builder .= " $this->PutAt"; |
if($this->PutAt != "") $builder .= " $this->PutAt"; |
||||
elseif ($this->PutInto != "") $builder .= " $this->PutInto"; |
elseif ($this->PutInto != "") $builder .= " $this->PutInto"; |
||||
else throw new QueryBuilderRequiredFieldIsNotSetException(); |
else throw new QueryBuilderRequiredFieldIsNotSetException(); |
||||
|
|
||||
if($this->Safe) $builder .= " SAFE"; |
if($this->Safe) $builder .= " SAFE"; |
||||
return $builder; |
return $builder; |
||||
} |
} |
||||
|
|
||||
|
|
||||
/** |
/** |
||||
* @throws QueryBuilderInvalidInputException |
* @throws QueryBuilderInvalidInputException |
||||
*/ |
*/ |
||||
public function Schema(string $uri): PutQuery |
public function Schema(string $uri): PutQueryBuilder |
||||
{ |
{ |
||||
$this->PutWhat = self::RegexValidate( |
$this->PutWhat = self::RegexValidate( |
||||
target: "SCHEMA \"$uri\"", |
target: "SCHEMA \"$uri\"", |
||||
pattern: "/SCHEMA \".+\"/" |
pattern: "/SCHEMA \".+\"/" |
||||
); |
); |
||||
return $this; |
return $this; |
||||
} |
} |
||||
|
|
||||
/** |
/** |
||||
* @throws QueryBuilderInvalidInputException |
* @throws QueryBuilderInvalidInputException |
||||
*/ |
*/ |
||||
public function URI(string $uri): PutQuery |
public function URI(string $uri): PutQueryBuilder |
||||
{ |
{ |
||||
$this->PutWhat = self::RegexValidate( |
$this->PutWhat = self::RegexValidate( |
||||
target: "URI \"$uri\"", |
target: "URI \"$uri\"", |
||||
pattern: "/URI \".+\"/" |
pattern: "/URI \".+\"/" |
||||
); |
); |
||||
return $this; |
return $this; |
||||
} |
} |
||||
|
|
||||
/** |
/** |
||||
* @throws QueryBuilderInvalidInputException |
* @throws QueryBuilderInvalidInputException |
||||
*/ |
*/ |
||||
public function DataURI(string $mimeType, string $data): PutQuery |
public function DataURI(string $mimeType, string $data): PutQueryBuilder |
||||
{ |
{ |
||||
$this->PutWhat = self::RegexValidate( |
$this->PutWhat = self::RegexValidate( |
||||
target: "URI \"data:$mimeType;$data\"", |
target: "URI \"data:$mimeType;$data\"", |
||||
pattern: "/URI \"data:[a-zA-Z0-9]/[a-zA-Z0-9];.+\"/" |
pattern: "/URI \"data:[a-zA-Z0-9]/[a-zA-Z0-9];.+\"/" |
||||
); |
); |
||||
return $this; |
return $this; |
||||
} |
} |
||||
|
|
||||
|
|
||||
/** |
/** |
||||
* @throws QueryBuilderInvalidInputException |
* @throws QueryBuilderInvalidInputException |
||||
* @throws QueryBuilderConflictingFieldAlreadyExistsException |
* @throws QueryBuilderConflictingFieldAlreadyExistsException |
||||
*/ |
*/ |
||||
public function At(string $node, string $uwu): PutQuery |
public function At(string $node, string $uwu): PutQueryBuilder |
||||
{ |
{ |
||||
self::EnsureNotSet($this->PutInto); |
self::EnsureNotSet($this->PutInto); |
||||
$this->PutAt = self::RegexValidate( |
$this->PutAt = self::RegexValidate( |
||||
target: 'AT {' . $node . '}/' . $uwu, |
target: 'AT {' . $node . '}/' . $uwu, |
||||
pattern: "/AT {[a-zA-Z0-9\-]+}\/[a-zA-Z0-9]+/" |
pattern: "/AT {[a-zA-Z0-9\-]+}\/[a-zA-Z0-9]+/" |
||||
); |
); |
||||
return $this; |
return $this; |
||||
} |
} |
||||
|
|
||||
|
|
||||
/** |
/** |
||||
* @throws QueryBuilderInvalidInputException |
* @throws QueryBuilderInvalidInputException |
||||
* @throws QueryBuilderConflictingFieldAlreadyExistsException |
* @throws QueryBuilderConflictingFieldAlreadyExistsException |
||||
*/ |
*/ |
||||
public function Into(string $relativePath, string $propertyName): PutQuery |
public function Into(string $relativePath, string $propertyName): PutQueryBuilder |
||||
{ |
{ |
||||
self::EnsureNotSet($this->PutAt); |
self::EnsureNotSet($this->PutAt); |
||||
$this->PutInto = self::RegexValidate( |
$this->PutInto = self::RegexValidate( |
||||
target: "INTO \"$relativePath\" AS \"$propertyName\"", |
target: "INTO \"$relativePath\" AS \"$propertyName\"", |
||||
pattern: "/INTO \"[a-zA-Z0-9\-]+\" AS \"[a-zA-Z0-9]+\"/" |
pattern: "/INTO \"[a-zA-Z0-9\-]+\" AS \"[a-zA-Z0-9]+\"/" |
||||
); |
); |
||||
return $this; |
return $this; |
||||
} |
} |
||||
|
|
||||
|
|
||||
public function Safe(): PutQuery |
public function Safe(): PutQueryBuilder |
||||
{ |
{ |
||||
$this->Safe = true; |
$this->Safe = true; |
||||
return $this; |
return $this; |
||||
} |
} |
||||
} |
} |
@ -0,0 +1,26 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\SelectQuery; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Core\DeegraphServer; |
||||
|
|
||||
|
class SelectQuery |
||||
|
{ |
||||
|
protected string $QueryString; |
||||
|
|
||||
|
public function __construct(string $queryString) |
||||
|
{ |
||||
|
$this->QueryString = $queryString; |
||||
|
} |
||||
|
|
||||
|
public function RunQuery(DeegraphServer $server): array |
||||
|
{ |
||||
|
$response = $server->RunRawRequest( |
||||
|
endpoint: "/api/v1/@query", |
||||
|
method: "POST", |
||||
|
body: $this->QueryString |
||||
|
); |
||||
|
$temp = json_decode($response, true); |
||||
|
return $temp; |
||||
|
} |
||||
|
} |
@ -1,66 +1,62 @@ |
|||||
<?php |
<?php |
||||
|
|
||||
namespace Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders; |
namespace Darksparrow\DeegraphInteractions\QueryBuilder\SelectQuery; |
||||
|
|
||||
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphEqualityOperator; |
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphEqualityOperator; |
||||
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderRequiredFieldIsNotSetException; |
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
|
||||
|
#[QueryBuilderQuery] |
||||
#[QueryBuilderQuery] |
final class SelectQueryBuilder implements SelectQueryBuilderInterface |
||||
final class SelectQuery |
{ |
||||
{ |
use QueryBuilderTrait; |
||||
use QueryBuilderTrait; |
|
||||
|
#[QueryBuilderRequiredField] |
||||
#[QueryBuilderRequiredField] |
protected array $RelativePaths = []; |
||||
protected array $RelativePaths = []; |
protected string $From = ""; |
||||
protected string $From = ""; |
protected string $Where = ""; |
||||
protected string $Where = ""; |
protected string $InstanceOf = ""; |
||||
protected string $InstanceOf = ""; |
|
||||
|
|
||||
|
public function __construct() |
||||
public function __construct() |
{ |
||||
{ |
} |
||||
} |
|
||||
|
public function RelativePath(string $relativePath): SelectQueryBuilder |
||||
/** |
{ |
||||
* @throws QueryBuilderRequiredFieldIsNotSetException |
$this->RelativePaths = [$relativePath]; |
||||
*/ |
return $this; |
||||
public function __toString(): string |
} |
||||
{ |
public function RelativePaths(array $relativePaths): SelectQueryBuilder |
||||
$builder = "SELECT "; |
{ |
||||
if(sizeof($this->RelativePaths)) $builder .= " " . implode(separator: ", ", array: $this->RelativePaths); |
$this->RelativePaths = $relativePaths; |
||||
if($this->From != "") $builder .= " FROM $this->From"; |
return $this; |
||||
if($this->Where != "") $builder .= " WHERE $this->Where"; |
} |
||||
if($this->InstanceOf != "") $builder .= " INSTANCEOF $this->InstanceOf"; |
public function From(string $target): SelectQueryBuilder |
||||
|
{ |
||||
return $builder; |
$this->From = "" . $target; |
||||
} |
return $this; |
||||
|
} |
||||
public function RelativePath(string $relativePath): SelectQuery |
public function Where(string $target, DeegraphEqualityOperator $operator, string $value): SelectQueryBuilder |
||||
{ |
{ |
||||
$this->RelativePaths = [$relativePath]; |
$this->Where = "" . $target . " " . $operator->value . " " . $value; |
||||
return $this; |
return $this; |
||||
} |
} |
||||
public function RelativePaths(array $relativePaths): SelectQuery |
public function InstanceOf(string $schema): SelectQueryBuilder |
||||
{ |
{ |
||||
$this->RelativePaths = $relativePaths; |
$this->InstanceOf = "" . $schema; |
||||
return $this; |
return $this; |
||||
} |
} |
||||
public function From(string $target): SelectQuery |
|
||||
{ |
public function Build(): SelectQuery |
||||
$this->From = "" . $target; |
{ |
||||
return $this; |
$builder = "SELECT "; |
||||
} |
if(sizeof($this->RelativePaths)) $builder .= " " . implode(separator: ", ", array: $this->RelativePaths); |
||||
public function Where(string $target, DeegraphEqualityOperator $operator, string $value): SelectQuery |
if($this->From != "") $builder .= " FROM $this->From"; |
||||
{ |
if($this->Where != "") $builder .= " WHERE $this->Where"; |
||||
$this->Where = "" . $target . " " . $operator->value . " " . $value; |
if($this->InstanceOf != "") $builder .= " INSTANCEOF $this->InstanceOf"; |
||||
return $this; |
|
||||
} |
return new SelectQuery(queryString: $builder); |
||||
public function InstanceOf(string $schema): SelectQuery |
} |
||||
{ |
|
||||
$this->InstanceOf = "" . $schema; |
|
||||
return $this; |
|
||||
} |
|
||||
} |
} |
@ -0,0 +1,8 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\SelectQuery; |
||||
|
|
||||
|
interface SelectQueryBuilderInterface |
||||
|
{ |
||||
|
public function Build() : SelectQuery; |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\SelectQuery; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\DataStructures\QueryResponseRow; |
||||
|
|
||||
|
class SelectQueryResponse |
||||
|
{ |
||||
|
public array $Rows; |
||||
|
public string $RowFormat; |
||||
|
|
||||
|
public function __construct(array $response) |
||||
|
{ |
||||
|
foreach($response["@rows"] as $row) |
||||
|
$this->Rows[] = new QueryResponseRow(array: $row); |
||||
|
$this->RowFormat = $response["@row_format"]; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue