forked from tom.biard/ScienceQuest
parent
a5bdc4fb90
commit
e64f991bd4
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class ThematiqueGateway
|
||||
{
|
||||
private $con;
|
||||
|
||||
function __construct(Connection $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
public function getFromId(int $id): array
|
||||
{
|
||||
$this->con->executeQuery("SELECT id, libelle FROM Thematique WHERE id=:id;",
|
||||
[':id' => [$id, $this->con::PARAM_INT]]);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class MdlThematique extends MdlBase{
|
||||
private ThematiqueGateway $gw;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->gw = new ThematiqueGateway($this->con);
|
||||
}
|
||||
|
||||
public function getFromId(int $id): Thematique{
|
||||
$row = $this->gw->getFromId($id);
|
||||
return new Thematique($row['id'], $row['libelle']);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class Thematique
|
||||
{
|
||||
private int $id;
|
||||
private string $libelle;
|
||||
|
||||
public function __construct(int $id, string $libelle)
|
||||
{
|
||||
$this->id=$id;
|
||||
$this->libelle=$libelle;
|
||||
}
|
||||
|
||||
public function getId():int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getLibelle(): string
|
||||
{
|
||||
return $this->libelle;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
enum Theme
|
||||
{
|
||||
case Maths;
|
||||
case Physics;
|
||||
case Chemistry;
|
||||
case Biology;
|
||||
}
|
Loading…
Reference in new issue