Merge branch 'master' of https://codefirst.iut.uca.fr/git/jade.van_brabandt/3.01-QCM_MuscuMaths
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
commit
333dceb0d3
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace gateways;
|
||||
|
||||
use usages\Connection;
|
||||
use \PDO;
|
||||
|
||||
class GatewayJouer
|
||||
{
|
||||
private $con;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $dns, $user, $pass;
|
||||
$this->con = new Connection($dns, $user, $pass);
|
||||
}
|
||||
|
||||
public function addJouer($jouer)
|
||||
{
|
||||
$query = "INSERT into jouer(idChapter,idPlayer,numScore) values (:idChapter,:idPlayer,:numScore);";
|
||||
$this->con->executeQuery(
|
||||
$query,
|
||||
array(
|
||||
'idChapter' => array($jouer['idChapter'], PDO::PARAM_STR),
|
||||
'idPlayer' => array($jouer['idPlayer'], PDO::PARAM_STR),
|
||||
':numScore' => array($jouer['numScore'], PDO::PARAM_INT)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getJouerByPlayerAndChapter(int $idPlayer, int $idChapter)
|
||||
{
|
||||
$query = "SELECT jouer.numScore FROM jouer,player WHERE jouer.idPlayer = :idPlayer AND jouer.idPlayer = player.id AND jouer.idChapter = :idChapter AND jouer.idChapter = chapter.id ;";
|
||||
$this->con->executeQuery(
|
||||
$query,
|
||||
array(
|
||||
':idChapter' => array($idChapter, PDO::PARAM_INT),
|
||||
':idPlayer' => array($idPlayer, PDO::PARAM_INT)
|
||||
)
|
||||
);
|
||||
$results = $this->con->getResults();
|
||||
return $results[0];
|
||||
}
|
||||
|
||||
public function updateJouer($idPlayer, $idChapter, $jouer)
|
||||
{
|
||||
$query = "UPDATE jouer SET numScore = :numScore WHERE idPlayer = :idPlayer AND idChapter = :idChapter;";
|
||||
$this->con->executeQuery(
|
||||
$query,
|
||||
array(
|
||||
':idChapter' => array($idChapter, PDO::PARAM_INT),
|
||||
':idPlayer' => array($idPlayer, PDO::PARAM_INT),
|
||||
':numScore' => array($jouer['numScore'], PDO::PARAM_INT)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function verifyJouer($idChapter, $idPlayer)
|
||||
{
|
||||
$query = "SELECT jouer.idChapter, jouer.idPlayer FROM jouer WHERE idPlayer = :idPlayer AND idChapter = :idChapter";
|
||||
$this->con->executeQuery(
|
||||
$query,
|
||||
array(
|
||||
':idChapter' => array($idChapter, PDO::PARAM_STR),
|
||||
':idPlayer' => array($idPlayer, PDO::PARAM_STR)
|
||||
)
|
||||
);
|
||||
$results = $this->con->getResults();
|
||||
return $results[0];
|
||||
}
|
||||
}
|
Loading…
Reference in new issue