HEX
Server: Apache
System: Linux v38079.2is.nl 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: democfellows (10015)
PHP: 8.1.34
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/creativefellows.nl/mygeomil.creativefellows.nl/03072023/src/Domain/Repository.php
<?php

namespace App\Domain;

use PDO;
use Psr\Container\ContainerInterface;

/**
 * Repository.
 */
abstract class Repository
{
	
    /**
     * @var PDO The database connection
     */
    private $connection;
	

    /**
     * Constructor.
     *
     * @param PDO $connection The database connection
     */
    public function __construct(
		PDO $connection,
		ContainerInterface $container
	){
        $this->connection 		= $connection;
		$this->container 		= $container;
		$this->items_per_page 	= $this->container->get("settings")["pagination"];
    }
		
    /**
     * Insert user row.
     *
     * @param string $sql The Query
     * @param array $parameters The parameters to bind
	 *
     * @return array The array with data
     */
	public function execute(string $sql, array $parameters = []): array
	{
	
		$sth = $this->connection->prepare($sql);			
		$sth->execute($parameters);
		 
		$row = $sth->fetch(); 
        return $row ? : [];
	}
	
	
	public function insert(string $sql, array $parameters = []): int
	{
	
		$sth = $this->connection->prepare($sql);			
		$sth->execute($parameters);
		
		return $this->connection->lastInsertId();	
	}
	
	public function patch(string $sql, array $parameters = [])
	{
	
		$sth = $this->connection->prepare($sql);			
		$sth->execute($parameters);
		
		//return $this->connection->lastInsertId();	
	}
	
	
    /**
     * Execute multiple row sql with given parameters
     *
     * @param string $sql The Query
     * @param array $parameters The parameters to bind
	 *
     * @return array The array with data
     */
	public function executeAll(string $sql, array $parameters = []): array
	{
	
		$sth = $this->connection->prepare($sql);			
		$sth->execute($parameters);
		 
		$row = $sth->fetchAll(); 
        return $row ? : [];
	}
	

}