Ajout de la classe Liste et liste Gateway, affiachage de tache ne fonctionne pas

pull/11/head
Rayhân HASSOU 2 years ago
parent e45ee52b3c
commit 7d758156fd

@ -45,6 +45,10 @@ case "seConnecter":
$this->seConnecter($dVueEreur);
break;
case "ConsulterListe":
$this->ConsulterListe();
break;
//mauvaise action
default:
$dVueEreur[] = "Erreur d'appel php";
@ -123,6 +127,18 @@ function seConnecter(array $dVueEreur) {
require ($rep.$vues['login']);
}
function ConsulterListe(){
global $rep,$vues;
$con=new Connection("mysql:host=localhost;dbname=dbrahassou","rahassou","achanger");
$model = new ListeGateway($con);
$results=array();
$results=$model->getListePublic(0,10);
$dVue = array (
'results' => $results
);
require ($rep.$vues['listeVue']);
}
}//fin class

@ -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;
}
}
?>

@ -23,6 +23,11 @@ class Tache
return $this->nom;
}
//Id
public function getid(){
return $this->id;
}
//Description
public function getDescription(){
return $this->description;

@ -5,20 +5,23 @@ class TacheGateway{
$this->con=$con;
}
public function Ajouter($nom, $description, Date $dateCreation, Utilisateur $createur){
$query='INSERT INTO Tache VALUES($nom, $description, dateCreation, $createur)';
public function Ajouter(string $nom, string $description, Date $dateCreation, bool $estValide, int $idCreateur){
$query='INSERT INTO ToDoList_Tache(nom, description, dateCreation,estValide, createur) VALUES(:nom, :description, :dateCreation, :estValide, :idCreateur)';
$this->con->executeQuery($query, array('nom' => array($nom, PDO::PARAM_STRING)),
array('description' => array($description, PDO::PARAM_STRING)),
array('dateCreation' => array($dateCreation, PDO::PARAM_STRING)),
array('estValide' => array($estValide, PDO::PARAM_BOOL)),
array('idCreateur' => array($idCreateur, PDO::PARAM_INT)))
}
public function Editer(Tache $tache, string $nom, string $description){
$query='UPDATE Tache SET :nom=$nom, :description=$description';
$this->con->executeQuery($query, array('nom' => array($tache->nom, PDO::PARAM_STRING)), array('description' => array($tache->description, PDO::PARAM_STRING)));
$query='UPDATE ToDoListe_Tache SET nom=:nom, description =:description WHERE id=:id';
$this->con->executeQuery($query, array('nom' => array($tache->getNom(), PDO::PARAM_STRING)), array('description' => array($tache->getdescription(), PDO::PARAM_STRING)), array('id' => array($tache->getId()),PDO::PARAM_INT));
}
public function Supprimer(Tache $tache){
$query='DELETE FROM Tache WHERE utilisateur=:utilisateur AND nom=:nom';
$this->con->executeQuery($query, array('utilisateur' => array($tache->createur, PDO::PARAM_INT),'nom' => array($tache->nom, PDO::PARAM_STRING)));
$query='DELETE FROM ToDoList_Tache WHERE id=:id';
$this->con->executeQuery($query,'id' => array($tache->getId(), PDO::PARAM_STRING)));
}
}
?>

@ -0,0 +1,9 @@
<?php
Foreach($results as $row)
{
print $row->getNom();
echo ("<br>");
print $row->getDateCreation();
echo ("<br>");
}
?>

@ -32,15 +32,27 @@
</form>
<form method="post">
<button type="submit" class="button-home">Les tâches publics</Button>
<input type="hidden" name="action" value="">
<input type="hidden" name="action" value="ConsulterListe">
</form>
</div>
</div>
</nav>
<br>
<?php
Foreach($results as $row)
{
print $row->getNom();
echo ("<br>");
print $row->getDateCreation();
echo ("<br>");
}
?>
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center >
<ul class="pagination justify-content-center">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>

@ -21,5 +21,6 @@ $vues['inscription']='Vue/html/inscription.html';
$vues['Home']='Vue/html/index.html';
$vues['login']='Vue/html/login.html';
$vues['profil']='Vue/html/profil.html';
$vues['listeVue']='Vue/html/ListeVue.php';
?>

Loading…
Cancel
Save