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.
		
		
		
		
		
			
		
			
				
					
					
						
							82 lines
						
					
					
						
							2.4 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							82 lines
						
					
					
						
							2.4 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\Wrappers;
							 | 
						|
								
							 | 
						|
								use App\API\Models\_DatabaseRecordPermissionSet;
							 | 
						|
								use App\API\Models\EnumeratorDetails;
							 | 
						|
								use App\API\Models\UserDetails;
							 | 
						|
								use App\Configuration;
							 | 
						|
								use Aura\SqlQuery\Common\DeleteInterface;
							 | 
						|
								use Aura\SqlQuery\Common\InsertInterface;
							 | 
						|
								use Aura\SqlQuery\Common\SelectInterface;
							 | 
						|
								use Aura\SqlQuery\Common\UpdateInterface;
							 | 
						|
								use Aura\SqlQuery\QueryFactory;
							 | 
						|
								use PDO;
							 | 
						|
								
							 | 
						|
								class DatabaseInteractions
							 | 
						|
								{
							 | 
						|
								    private PDO $pdo;
							 | 
						|
								
							 | 
						|
								    public function __construct()
							 | 
						|
								    {
							 | 
						|
								        $servername = Configuration::GetConfig('MariaDB', 'Host');
							 | 
						|
								        $database = Configuration::GetConfig('MariaDB', 'Database');
							 | 
						|
								        $username = Configuration::GetConfig('MariaDB', 'Username');
							 | 
						|
								        $password = Configuration::GetConfig('MariaDB', 'Password');
							 | 
						|
								
							 | 
						|
								        $this->pdo = new PDO(
							 | 
						|
								            "mysql:host=$servername;dbname=$database", $username, $password
							 | 
						|
								        );
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function ScheduleRowForDeletion(string $tableName, string $id)
							 | 
						|
								    {
							 | 
						|
								
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    public function RunSelect(SelectInterface $queryBuilder): array
							 | 
						|
								    {
							 | 
						|
								        $sth = $this->pdo->prepare($queryBuilder->getStatement());
							 | 
						|
								        $sth->execute($queryBuilder->getBindValues());
							 | 
						|
								        $result = $sth->fetchAll(PDO::FETCH_ASSOC);
							 | 
						|
								        return $result;
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function RunOneSelect(SelectInterface $queryBuilder): array
							 | 
						|
								    {
							 | 
						|
								        $sth = $this->pdo->prepare($queryBuilder->getStatement());
							 | 
						|
								        $sth->execute($queryBuilder->getBindValues());
							 | 
						|
								        $result = $sth->fetchAll(PDO::FETCH_ASSOC);
							 | 
						|
								        if(sizeof($result) == 1) return $result[0];
							 | 
						|
								
							 | 
						|
								        echo "invalid single row db response";
							 | 
						|
								        die();
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function UpdateSingleField(UpdateInterface $queryBuilder): void
							 | 
						|
								    {
							 | 
						|
								        $sth = $this->pdo->prepare($queryBuilder->getStatement());
							 | 
						|
								        $sth->execute($queryBuilder->getBindValues());
							 | 
						|
								        $result = $sth->fetchAll(PDO::FETCH_ASSOC);
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function RunInsert(InsertInterface $queryBuilder): bool
							 | 
						|
								    {
							 | 
						|
								        $sth = $this->pdo->prepare($queryBuilder->getStatement());
							 | 
						|
								        return $sth->execute($queryBuilder->getBindValues());
							 | 
						|
								    }
							 | 
						|
								    public function RunUpdate(UpdateInterface $queryBuilder): bool
							 | 
						|
								    {
							 | 
						|
								        $sth = $this->pdo->prepare($queryBuilder->getStatement());
							 | 
						|
								        return $sth->execute($queryBuilder->getBindValues());
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function RunDelete(DeleteInterface $queryBuilder): bool
							 | 
						|
								    {
							 | 
						|
								        $sth = $this->pdo->prepare($queryBuilder->getStatement());
							 | 
						|
								        return $sth->execute($queryBuilder->getBindValues());
							 | 
						|
								    }
							 | 
						|
								}
							 | 
						|
								
							 |