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.
		
		
		
		
		
			
		
			
				
					
					
						
							61 lines
						
					
					
						
							1.9 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							61 lines
						
					
					
						
							1.9 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders;
							 | 
						|
								
							 | 
						|
								use Darksparrow\DeegraphPHP\Attributes\QueryBuilderQuery;
							 | 
						|
								use Darksparrow\DeegraphPHP\Attributes\QueryBuilderRequiredField;
							 | 
						|
								use Darksparrow\DeegraphPHP\Enumerators\DeegraphEqualityOperator;
							 | 
						|
								use Darksparrow\DeegraphPHP\Exceptions\QueryBuilderRequiredFieldIsNotSetException;
							 | 
						|
								use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilderTrait;
							 | 
						|
								
							 | 
						|
								#[QueryBuilderQuery]
							 | 
						|
								final class SelectQuery
							 | 
						|
								{
							 | 
						|
								    use QueryBuilderTrait;
							 | 
						|
								
							 | 
						|
								    #[QueryBuilderRequiredField]
							 | 
						|
								    protected array $RelativePaths = [];
							 | 
						|
								    protected string $From = "";
							 | 
						|
								    protected string $Where = "";
							 | 
						|
								    protected string $InstanceOf = "";
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    public function __construct()
							 | 
						|
								    {
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * @throws QueryBuilderRequiredFieldIsNotSetException
							 | 
						|
								     */
							 | 
						|
								    public function __toString(): string
							 | 
						|
								    {
							 | 
						|
								        $builder = "SELECT ";
							 | 
						|
								        if(sizeof($this->RelativePaths)) $builder .= " " . implode(separator: ", ", array: $this->RelativePaths);
							 | 
						|
								        if($this->From != "") $builder .= " FROM $this->From";
							 | 
						|
								        if($this->Where != "") $builder .= " WHERE $this->Where";
							 | 
						|
								        if($this->InstanceOf != "") $builder .= " INSTANCEOF $this->InstanceOf";
							 | 
						|
								
							 | 
						|
								        return $builder;
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function RelativePaths(array $relativePaths): SelectQuery
							 | 
						|
								    {
							 | 
						|
								        $this->RelativePaths = $relativePaths;
							 | 
						|
								        return $this;
							 | 
						|
								    }
							 | 
						|
								    public function From(string $target): SelectQuery
							 | 
						|
								    {
							 | 
						|
								        $this->From = "" . $target;
							 | 
						|
								        return $this;
							 | 
						|
								    }
							 | 
						|
								    public function Where(string $target, DeegraphEqualityOperator $operator, string $value): SelectQuery
							 | 
						|
								    {
							 | 
						|
								        $this->Where = "" . $target . " " . $operator->value . " " . $value;
							 | 
						|
								        return $this;
							 | 
						|
								    }
							 | 
						|
								    public function InstanceOf(string $schema): SelectQuery
							 | 
						|
								    {
							 | 
						|
								        $this->InstanceOf = "" . $schema;
							 | 
						|
								        return $this;
							 | 
						|
								    }
							 | 
						|
								}
							 |