Obvody/app/Model/ObvodFacade.php

47 lines
950 B
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use Nette;
use Nette\Database\Explorer;
use Nette\Database\Row;
use Nette\Security\User;
use Nette\Utils\DateTime;
/**
* Třída pro načítání informací o obvodech z DB.
*/
final class ObvodFacade
{
public function __construct(
private Explorer $database,
private User $user,
) {
}
/**
* Základní informace o obvodu.
* @param int $id
* @return Nette\Database\Table\ActiveRow|null
*/
public function getObvod(int $id): Row|null
{
$sql = "SELECT *
FROM OBVOD
WHERE OBVOD.ID = ?";
return $this->database->fetch($sql, $id);
}
/**
* Základní informace o obvodech.
* @return Nette\Database\Table\ActiveRow|null
*/
public function getObvody(): array
{
$sql = "SELECT * FROM OBVOD";
return $this->database->fetchAll($sql );
}
}