parent
e45ee52b3c
commit
7d758156fd
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace modeles;
|
||||||
|
|
||||||
|
class Liste
|
||||||
|
{
|
||||||
|
private string $id;
|
||||||
|
private string $nom;
|
||||||
|
private Date $dateCreation;
|
||||||
|
private bool $estValide;
|
||||||
|
private array $liste;
|
||||||
|
|
||||||
|
public function __construct(string $id, string $nom, Date $dateCreation, array $liste){
|
||||||
|
$this->id = $id;
|
||||||
|
$this->nom = $nom;
|
||||||
|
$this->description = $description;
|
||||||
|
$this->dateCreation = $dateCreation;
|
||||||
|
$this->estValide = false;
|
||||||
|
$this->liste = $liste;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Nom
|
||||||
|
public function getNom(){
|
||||||
|
return $this->nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Id
|
||||||
|
public function getid(){
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
//DateCreation
|
||||||
|
public function getDateCreation(){
|
||||||
|
return $this->dateCreation;
|
||||||
|
}
|
||||||
|
|
||||||
|
//EstValide
|
||||||
|
public function getEstValide(){
|
||||||
|
return $this->estValide;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getListe(){
|
||||||
|
return $this->liste;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
class ListeGateway{
|
||||||
|
private $con;
|
||||||
|
|
||||||
|
public function __construct(Connection $con){
|
||||||
|
$this->con=$con;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Ajouter(string $nom, Date $dateCreation, bool $estValide, int $idCreateur, bool $estPublic){
|
||||||
|
$query='INSERT INTO ToDoList_Liste(nom, dateCreation,estValide, createur, estPublic) VALUES(:nom, :dateCreation, :estValide, :idCreateur, :estPublic)';
|
||||||
|
$this->con->executeQuery($query, array('nom' => array($nom, PDO::PARAM_STRING)),
|
||||||
|
array('dateCreation' => array($dateCreation, PDO::PARAM_STRING)),
|
||||||
|
array('estValide' => array($estValide, PDO::PARAM_BOOL)),
|
||||||
|
array('idCreateur' => array($idCreateur, PDO::PARAM_INT)),
|
||||||
|
array('estPublic' => array($estPublic, PDO::PARAM_INT))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Editer(Liste $Liste, string $nom,){
|
||||||
|
$query='UPDATE ToDoListe_Liste SET nom=:nom WHERE id=:id';
|
||||||
|
$this->con->executeQuery($query, array('nom' => array($Liste->getNom(), PDO::PARAM_STRING)), array('id' => array($Liste->getId()),PDO::PARAM_INT));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function Supprimer(Liste $liste){
|
||||||
|
$query='DELETE FROM ToDoListe_Liste WHERE id=:id';
|
||||||
|
$this->con->executeQuery($query,'id' => array($liste->id, PDO::PARAM_STRING)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getListe(int $offset, int $limit){
|
||||||
|
$query = "SELECT * FROM ToDoListe_Liste LIMITS $offset,$limit";
|
||||||
|
$this->con->executeQuery($query);
|
||||||
|
$results=$this->con->getResults();
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTacheListe(Liste $liste){
|
||||||
|
$query = 'SELECT tache FROM ToDoListe_Liste WHERE id=:id ';
|
||||||
|
$this->con->executeQuery($query, array('id' => array($liste->getId, PDO::PARAM_INT)));
|
||||||
|
$results=$this->con->getResults();
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getListePublic($offset,$limit){
|
||||||
|
$query = "SELECT * FROM ToDoListe_Liste AND isPublic LIMITS $offset,$limit";
|
||||||
|
$this->con->executeQuery($query);
|
||||||
|
$results=$this->con->getResults();
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
Foreach($results as $row)
|
||||||
|
{
|
||||||
|
print $row->getNom();
|
||||||
|
echo ("<br>");
|
||||||
|
print $row->getDateCreation();
|
||||||
|
echo ("<br>");
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in new issue