You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Scripted/WEB/Controller/JoueurGateway.php

51 lines
1.3 KiB

<?php
require_once "../Model/Joueur.php";
require_once "../Config/Connection.php";
class JoueurGateway
{
private Connection $con;
/**
* @param Connection $con
*/
public function __construct(Connection $con){
$this->con = $con;
}
/**
* @param Connection $con
*/
public function setCon(Connection $con): void
{
$this->con = $con;
}
public function insert(Joueur $joueur) : void{
$query = "INSERT INTO Joueur VALUE (:email,:pseudo,:mdp)";
$this->con->executeQuery($query, array(
':email' => array($joueur->getEmail(),PDO::PARAM_STR),
':pseudo' => array($joueur->getPseudo(),PDO::PARAM_STR),
':mdp' => array($joueur->getMdp(),PDO::PARAM_STR)));
}
public function delete(string $email) : void{
$query = "DELETE FROM Joueur WHERE email=:email";
$this->con->executeQuery($query, array(
':email' => array($email,PDO::PARAM_STR)
));
}
public function showAll() : void{
$query = "SELECT * FROM Joueur";
$this->con->executeQuery($query);
$results=$this->con->getResults();
foreach ($results as $row) {
echo $row['email'] . '</br>';
echo $row['pseudo'] . '</br>';
echo $row['mdp'] . '</br>';
}
}
}