Merge pull request 'solidification' (#21) from solidification into master

Reviewed-on: WikiFantasy/WF-Website#21
pull/22/head
Kentin BRONGNIART 5 months ago
commit f41903f36f

@ -5,16 +5,9 @@ use Connection;
use PDO;
class CharacterGateway
class CharacterGateway extends Gateway
{
private Connection $co;
public function __construct(Connection $co)
{
$this -> co = $co;
}
public function create(int $id_character, string $name , string $img_char) : bool
{
$query = "

@ -2,11 +2,7 @@
namespace Gateway;
use PDO;
class CommentaryGateway {
private Connection $co ;
public function __construct(Connection $co) {
$this->co = $co;
}
class CommentaryGateway extends Gateway{
public function firstIdComment():int{
$query = "Select id_comment from Commentary;";

@ -3,14 +3,8 @@
namespace Gateway;
use PDO;
class FavoriteGateway
class FavoriteGateway extends Gateway
{
private Connection $co;
public function __construct(Connection $co)
{
$this -> co = $co;
}
public function createFavoriteGateway(int $idUser, int $idQuote) : bool
{

@ -3,12 +3,12 @@ namespace Gateway;
use PDO;
class AccueilGateway {
class Gateway {
private Connection $con;
protected Connection $co;
public function __construct(Connection $con) {
$this->con = $con;
$this->co = $con;
}

@ -3,14 +3,8 @@
namespace Gateway;
use PDO;
class ImageGateway
class ImageGateway extends Gateway
{
private Connection $co;
public function __construct(Connection $co)
{
$this -> co = $co;
}
public function createImgGateway(int $idImg, string $imgPath, bool $isImgProfile) : bool
{

@ -3,14 +3,8 @@ namespace Gateway;
use Gateway\Connection;
use PDO;
class QuestionGateway
class QuestionGateway extends Gateway
{
private Connection $co;
public function __construct(Connection $co)
{
$this -> co = $co;
}
public function create(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer): bool
{

@ -5,14 +5,8 @@ use Gateway\Connection;
use PDO;
class QuizGateway
class QuizGateway extends Gateway
{
private Connection $co;
public function __construct(Connection $co)
{
$this -> co = $co;
}
public function create(int $id_quiz, int $nb_questions) : bool
{

@ -3,14 +3,8 @@
namespace Gateway;
use PDO;
class QuizQuestionGateway
class QuizQuestionGateway extends Gateway
{
private Connection $co;
public function __construct(Connection $co)
{
$this -> co = $co;
}
public function createQuizQuestionGateway(int $idQuiz, int $idQuestion): bool
{

@ -1,19 +1,14 @@
<?php
namespace Gateway;
use PDO;
Class QuoteGateway{
private Connection $con;
public function __construct(Connection $con){
$this->con=$con;
}
Class QuoteGateway extends Gateway{
public function searchQuote(string $quote,int $numpage,string $language):array{
//recherche par citation
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE content LIKE '%:quote%' AND isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
$this->con->executeQuery($query,array(':quote' => array($quote,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
$result=$this->con->getResults();
$this->co->executeQuery($query,array(':quote' => array($quote,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
@ -21,8 +16,8 @@ Class QuoteGateway{
//recherche par source
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE s.title LIKE '%:source%' AND q.isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
$this->con->executeQuery($query,array(':source' => array($source,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
$result=$this->con->getResults();
$this->co->executeQuery($query,array(':source' => array($source,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
@ -30,8 +25,8 @@ Class QuoteGateway{
//recherche par personnage
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE c.caracter LIKE '%:pers%' AND q.isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
$this->con->executeQuery($query,array(':pers' => array($Pers,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
$result=$this->con->getResults();
$this->co->executeQuery($query,array(':pers' => array($Pers,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
@ -39,8 +34,8 @@ Class QuoteGateway{
//recherche par id
$query="SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dates, q.likes, q.langue FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source JOIN Image i ON c.id_img = i.id_img WHERE q.id_quote = :id AND q.isvalide = true;";
$this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
$result=$this->con->getResults();
$this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
@ -66,9 +61,9 @@ Class QuoteGateway{
$query = $query . " AND " . $fil
}*/
$this->con->executeQuery($query,array());
$this->co->executeQuery($query,array());
$result=$this->con->getResults();
$result=$this->co->getResults();
return $result;
}
@ -83,14 +78,15 @@ Class QuoteGateway{
ORDER BY q.id_quote DESC
LIMIT 1;";
try {
$this->con->executeQuery($query, [':language' => [$language, PDO::PARAM_STR]]);
$result = $this->con->getResults();
$this->co->executeQuery($query, [':language' => [$language, PDO::PARAM_STR]]);
$result = $this->co->getResults();
return $result[0] ?? [];
} catch (PDOException $e) {
echo "Erreur dans getQuoteOfTheDay: " . $e->getMessage();
return [];
}
}
}
public function getSuggestions(int $numpage, string $language): array {
@ -103,11 +99,11 @@ Class QuoteGateway{
ORDER BY RANDOM()
LIMIT 20 OFFSET :offset;";
$this->con->executeQuery($query, [
$this->co->executeQuery($query, [
':language' => [$language, PDO::PARAM_STR],
':offset' => [$numpage * 20, PDO::PARAM_INT]
]);
return $this->con->getResults();
return $this->co->getResults();
}
public function getFavorites(string $userId): array {
@ -120,10 +116,10 @@ Class QuoteGateway{
WHERE f.users = :userId";
try {
$this->con->executeQuery($query, [
$this->co->executeQuery($query, [
':userId' => [$userId, PDO::PARAM_STR]
]);
return $this->con->getResults();
return $this->co->getResults();
} catch (PDOException $e) {
echo "Erreur dans getFavorites: " . $e->getMessage();
return [];
@ -136,21 +132,21 @@ Class QuoteGateway{
public function getQuoteIsValide():array{
//obtenir les quotes en attentes de validation par l'admin
$query = 'SELECT * FROM Quote WHERE isValid=:bool';
$this->con->executeQuery($query,array(':bool' => array(false, PDO::PARAM_BOOL)));
$result=$this->con->getResults();
$this->co->executeQuery($query,array(':bool' => array(false, PDO::PARAM_BOOL)));
$result=$this->co->getResults();
return $result;
}
public function validQuote(int $id){
//Valider la quote par l'admin
$query ='UPDATE Quote SET isValid=:newValide WHERE id_Quote=:id';
$this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT)));
$this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT)));
}
public function invalidQuote(int $id){
//Invalide la quote par l'admin (suppression)
$query ='DELETE FROM Quote WHERE id_Quote=:id';
$this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT)));
$this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT)));
}
public function updateContent(int $id, string $newContent):array{

@ -4,14 +4,8 @@ namespace Gateway;
use PDO;
class ResultsGateway
class ResultsGateway extends Gateway
{
private Connection $co;
public function __construct(Connection $co)
{
$this -> co = $co ;
}
public function createResultsGateway(int $idQuiz, int $idUser, int $nbPts, int $time) : bool
{

@ -2,27 +2,21 @@
namespace Gateway;
use PDO;
Class UserGateway{
private Connection $con;
public function __construct(Connection $con){
$this->con=$con;
}
Class UserGateway extends Gateway{
public function getNumberOfUsers() : array
{
$query = "SELECT Count(*) FROM Users";
$this -> con -> executeQuery($query);
$this -> co -> executeQuery($query);
return $this -> con -> getResults();
return $this -> co -> getResults();
}
public function firstIdUser():int{
$query = "Select id_user from Users;";
$this -> con -> executeQuery($query);
$res = $this -> con -> getResults();
$this -> co -> executeQuery($query);
$res = $this -> co -> getResults();
foreach($res as $r){
$tab[] = $r["id_user"];
}
@ -37,7 +31,7 @@ Class UserGateway{
INSERT INTO Users(id_user,username,email,password,creation,img)
VALUES (:id, :pseudo, :email, :password, CURRENT_DATE, :imgPrfl);
";
return $this -> con -> executeQuery($query, [
return $this -> co -> executeQuery($query, [
":id" => [$id, PDO::PARAM_INT],
":pseudo" => [$pseudo, PDO::PARAM_STR],
":email" => [$email, PDO::PARAM_STR],
@ -51,15 +45,15 @@ Class UserGateway{
// supretion user
$query='DELETE FROM Users WHERE id_user = :id;';
return $this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
return $this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
}
public function getFavorite(string $id):array{
//obtention favoris d'un user
$query='SELECT * FROM Quote WHERE id_quote IN (SELECT id_quote FROM Favorite f JOIN users u ON u.id_user = f.user_f WHERE u.id_user = :id);';
$this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
$result=$this->con->getResults();
$this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
@ -67,22 +61,22 @@ Class UserGateway{
//obtenir les information d'un user
public function findDataUser(int $id):array{
$query = 'SELECT * FROM Users WHERE id_user=:idUser';
$this->con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $this->con->getResults();
$this->co->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $this->co->getResults();
return $result;
}
// obtenir les informations d'un user selon son pseudo
public function findUsername(string $username):array{
$query = 'SELECT u.id_user , u.username , u.email , u.password , i.imgPath , u.creation FROM Users u Join Image i on i.id_img=u.img WHERE username= :username';
$this->con->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR)));
return $this->con->getResults();
$this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function findEmail(string $email):array{
$query = 'SELECT * FROM Users WHERE email = :email';
$this->con->executeQuery($query, array(':email'=>array($email, PDO::PARAM_STR)));
return $this->con->getResults();
$this->co->executeQuery($query, array(':email'=>array($email, PDO::PARAM_STR)));
return $this->co->getResults();
}
// ===================== UPDATE FUNCTION =====================
@ -90,46 +84,46 @@ Class UserGateway{
public function updateUsername(int $id, string $newUsername):bool{
//Update le nom du user passé en paramètre
$queryUpdate = 'UPDATE Users SET username=:newUsername WHERE id_user=:idUser';
$this->con->executeQuery($queryUpdate, array(':idUser'=>array($id, PDO::PARAM_STR), ':newUsername'=> array($newUsername, PDO::PARAM_STR)));
$this->co->executeQuery($queryUpdate, array(':idUser'=>array($id, PDO::PARAM_STR), ':newUsername'=> array($newUsername, PDO::PARAM_STR)));
//Renvoie le nouveau nom du user
$queryReponse = 'SELECT username FROM Users WHERE id_user=:idUser';
return $this->con->executeQuery($queryReponse, array($id=>array($newUsername, PDO::PARAM_STR)));
return $this->co->executeQuery($queryReponse, array($id=>array($newUsername, PDO::PARAM_STR)));
}
public function updateEmail(int $id, string $newEmail):bool{
//Update le email du user passé en paramètre
$queryUpdate = 'UPDATE Users SET email=:newEmail WHERE id_user=:idUser';
$this->con->executeQuery($queryUpdate, array(':idUser'=>array($id, PDO::PARAM_STR), ':newEmail'=> array($newEmail, PDO::PARAM_STR)));
$this->co->executeQuery($queryUpdate, array(':idUser'=>array($id, PDO::PARAM_STR), ':newEmail'=> array($newEmail, PDO::PARAM_STR)));
//Renvoie le nouveau email du user
$queryReponse = 'SELECT email FROM Users WHERE id_user=:idUser';
return $this->con->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
return $this->co->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
}
public function updateImg(int $id, int $newImg):array{
//Update l'image du user passé en paramètre
$query = 'UPDATE Users SET img_prfl=:newImg WHERE id_user=:idUser';
$this->con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR), ':newImg'=> array($newImg, PDO::PARAM_STR)));
$this->co->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR), ':newImg'=> array($newImg, PDO::PARAM_STR)));
//Renvoie la nouvelle image du user
$queryReponse = 'SELECT img_prfl FROM Users WHERE id_user=:idUser';
$this->con->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $this->con->getResults();
$this->co->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $this->co->getResults();
return $result;
}
public function updatePasswd(int $id, string $newPassWd):array{
//Update le passwd du user passé en paramètre
$query = 'UPDATE Users SET pssword=:newPassWd WHERE id_user=:idUser';
$this->con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR), ':newPassWd'=> array($newPassWd, PDO::PARAM_STR)));
$this->co->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR), ':newPassWd'=> array($newPassWd, PDO::PARAM_STR)));
}
public function getIdUser(string $username):array{
$query = 'SELECT id_user FROM Users WHERE username=:username';
$this->con->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR)));
$result = $this->con->getResults();
$this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR)));
$result = $this->co->getResults();
return $result;
}

@ -2,14 +2,7 @@
namespace Gateway;
use Connection;
class SourceGateway {
private Connection $co;
public function __construct(Connection $co)
{
$this -> co = $co;
}
class SourceGateway extends Gateway{
public function create(sourceEntity $s) : bool
{

@ -3,18 +3,12 @@
namespace Model;
use Entity\CharacterEntity;
use Gateway\CharacterGateway;
use Gateway\Gateway;
class CharacterModel
class CharacterModel extends Model
{
private CharacterGateway $gateway;
public function __construct(characterGateway $gw)
{
$this -> gateway = $gw;
}
public function createCharacter(int $id_character, string $name , string $img_char) : bool
{
return $this -> gateway -> create($id_character, $name, $img_char);

@ -2,22 +2,17 @@
namespace Model;
use Entity\CommentaryEntity;
use Gateway\CommentaryGateway;
use Gateway\Gateway;
class CommentaryModel {
private commentaryGateway $gw;
function __construct(commentaryGateway $gw) {
$this->gw = $gw;
}
class CommentaryModel extends Model {
public function createComment(string $comment, string $idQuote, string $idUser): bool {
return $this->gw->create($comment, $idUser, $idQuote);
return $this->gateway->create($comment, $idUser, $idQuote);
}
public function getComment(int $id): array {
$com = [];
$res = $this->gw->findByQuote($id);
$res = $this->gateway->findByQuote($id);
foreach ($res as $comments){
$com[] = new CommentaryEntity($comments["id_comment"], $comments["comment"], $comments["datec"], $comments["username"]);
}
@ -25,7 +20,7 @@ class CommentaryModel {
}
public function getComments(): array {
$res = $this->gw->findAll();
$res = $this->gateway->findAll();
foreach ($res as $comments) {
$com[] = new CommentaryEntity($comments["id_comment"], $comments["comment"], $comments["date"]);
}
@ -33,7 +28,7 @@ class CommentaryModel {
}
public function deleteComment(int $id_comment): bool {
return $this -> gw -> delete($id_comment);
return $this -> gateway -> delete($id_comment);
}
public function updateComment(int $id_comment, string $comment): bool {
@ -42,7 +37,7 @@ class CommentaryModel {
if($c){
$c -> setComment($comment);
return $this->gw -> update($c);
return $this->gateway -> update($c);
}
return false;
}

@ -3,24 +3,18 @@
namespace Model;
use Gateway\FavoriteGateway;
use Entity\FavoriteEntity;
use Gateway\Gateway;
class FavoriteModel
class FavoriteModel extends Model
{
private FavoriteGateway $gw;
public function __construct(FavoriteGateway $gw)
{
$this -> gw = $gw;
}
public function createFavoriteModel(int $idUser, int $idQuote) : bool
{
return $this -> gw -> createFavoriteGateway($idUser, $idQuote);
return $this -> gateway -> createFavoriteGateway($idUser, $idQuote);
}
public function getFavoriteById(int $idUser, int $idQuote) : ?FavoriteEntity
{
$res = $this -> gw -> findFavoriteById($idUser, $idQuote);
$res = $this -> gateway -> findFavoriteById($idUser, $idQuote);
if ($res)
{
@ -34,7 +28,7 @@ class FavoriteModel
public function getFavoriteByUser(int $idUser) : array
{
$res = $this -> gw -> findFavoriteByUser($idUser);
$res = $this -> gateway -> findFavoriteByUser($idUser);
$favorites = [];
@ -50,7 +44,7 @@ class FavoriteModel
public function getAllFavorite() : array
{
$res = $this -> gw -> findAllFavorite();
$res = $this -> gateway -> findAllFavorite();
$favorites = [];
@ -66,6 +60,6 @@ class FavoriteModel
public function removeFavorite(int $idUser, int $idQuote) : bool
{
return $this -> gw -> deleteFavoriteGateway($idUser, $idQuote);
return $this -> gateway -> deleteFavoriteGateway($idUser, $idQuote);
}
}

@ -4,24 +4,18 @@ namespace Model;
use Entity\ImageEntity;
use Gateway\ImageGateway;
use Gateway\Gateway;
class ImageModel
class ImageModel extends Model
{
private ImageGateway $gw;
public function __construct(ImageGateway $gw)
{
$this -> gw = $gw;
}
public function createImgModel(int $idImg, string $imgPath, bool $isImgProfile) : bool
{
return $this -> gw -> createImgGateway($idImg, $imgPath, $isImgProfile);
return $this -> gateway -> createImgGateway($idImg, $imgPath, $isImgProfile);
}
public function getImgById(int $idImg) : ?ImageEntity
{
$res = $this -> gw -> findImgById($idImg);
$res = $this -> gateway -> findImgById($idImg);
if ($res)
{
@ -36,7 +30,7 @@ class ImageModel
public function getAllImg() : array
{
$res = $this -> gw -> findAllImg();
$res = $this -> gateway -> findAllImg();
$images = [];
@ -53,7 +47,7 @@ class ImageModel
public function getAllImgProfile() : array
{
$res = $this -> gw -> findAllImgProfile();
$res = $this -> gateway -> findAllImgProfile();
$images = [];
@ -70,11 +64,11 @@ class ImageModel
public function deleteImgModel(int $idImg) : bool
{
return $this -> gw -> deleteImgGateway($idImg);
return $this -> gateway -> deleteImgGateway($idImg);
}
public function updateImgModel(int $idImg, string $imgPath) : bool
{
return $this -> gw -> updateImgGateway($idImg, $imgPath);
return $this -> gateway -> updateImgGateway($idImg, $imgPath);
}
}

@ -0,0 +1,14 @@
<?php
namespace Model;
use Gateway\Gateway;
class Model
{
protected Gateway $gateway;
public function __construct(Gateway $gate){
$this->gateway = $gate;
}
}
?>

@ -3,16 +3,10 @@
namespace Model;
use Gateway\QuestionGateway;
use Entity\QuestionEntity;
use Gateway\Gateway;
class QuestionModel
class QuestionModel extends Model
{
private QuestionGateway $gateway;
public function __construct(QuestionGateway $gw)
{
$this -> gateway = $gw;
}
public function createQuestion(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer): bool
{
return $this -> gateway -> create($id_question, $question, $answerA, $answerB, $answerC, $answerD, $cAnswer);

@ -4,16 +4,10 @@ namespace Model;
use Entity\quizEntity;
use Gateway\QuizGateway;
use Gateway\Gateway;
class QuizModel {
private QuizGateway $gateway;
public function __construct(QuizGateway $gw)
{
$this -> gateway = $gw;
}
class QuizModel extends Model{
public function createQuiz(int $id_quiz, int $nb_questions) : bool
{
return $this -> gateway -> create($id_quiz, $nb_questions);

@ -9,27 +9,19 @@ use Gateway\Connection;
use Gateway\QuestionGateway;
use Gateway\QuizGateway;
use Gateway\QuizQuestionGateway;
use Gateway\Gateway;
class QuizQuestionModel
class QuizQuestionModel extends Model
{
private QuizQuestionGateway $gw;
/**
* @param QuizGateway $gw
*/
public function __construct(QuizQuestionGateway $gw)
{
$this->gw = $gw;
}
public function createQuizQuestion(int $idQuiz, int $idQuestion): bool
{
return $this->gw->create($idQuiz,$idQuestion);
return $this->gateway->create($idQuiz,$idQuestion);
}
public function findQuizQuestionByIdQuiz(int $id): ?QuizQuestionEntity
{
$q = $this ->gw->findQuizQuestionByIdQuiz($id);
$q = $this ->gateway->findQuizQuestionByIdQuiz($id);
if ($q) {
return new QuizQuestionEntity(
$q['idQuiz'],
@ -41,11 +33,11 @@ class QuizQuestionModel
public function getAllQuestionByQuiz(int $id, Connection $co): array
{
$q = $this->gw->findQuestionsFromQuiz($id);
$q = $this->gateway->findQuestionsFromQuiz($id);
$questions = [];
$gw = new QuestionGateway($co);
$qmdl = new QuestionModel($gw);
$gateway = new QuestionGateway($co);
$qmdl = new QuestionModel($gateway);
foreach ($q as $question){
$questions [] = $qmdl->getQuestion($question[1]);
@ -56,7 +48,7 @@ class QuizQuestionModel
public function findAll(): array
{
$q = $this -> gw -> findAll();
$q = $this -> gateway -> findAll();
$quizzes = [];
@ -71,7 +63,7 @@ class QuizQuestionModel
public function deleteQuizQuestion(int $id): bool
{
return $this -> gw -> delete($id);
return $this -> gateway -> delete($id);
}

@ -2,14 +2,10 @@
namespace Model;
use Entity\Quote;
use Gateway\QuoteGateway;
use Gateway\Gateway;
class QuoteModel
class QuoteModel extends Model
{
private QuoteGateway $gateway;
public function __construct(QuoteGateway $gate){
$this->gateway = $gate;
}
public function searchId(int $id): Quote{
$res = $this->gateway->searchId($id);

@ -4,24 +4,19 @@ namespace Model;
use Entity\ResultsEntity;
use Gateway\ResultsGateway;
use Gateway\Gateway;
class ResultsModel
class ResultsModel extends Model
{
private ResultsGateway $gw;
public function __construct(ResultsGateway $gw)
{
$this -> gw = $gw;
}
public function createResultsModel(int $idQuiz, int $idUser, int $score, int $time) : bool
{
return $this -> gw -> createResultsGateway($idQuiz, $idUser, $score, $time);
return $this -> gateway -> createResultsGateway($idQuiz, $idUser, $score, $time);
}
public function getResultsByQuiz(int $idQuiz) : array
{
$res = $this -> gw -> findResultsByQuiz($idQuiz);
$res = $this -> gateway -> findResultsByQuiz($idQuiz);
$results = [];
@ -39,7 +34,7 @@ class ResultsModel
public function getResultsByUser(int $idUser) : array
{
$res = $this -> gw -> findResultsByUser($idUser);
$res = $this -> gateway -> findResultsByUser($idUser);
$results = [];
@ -57,7 +52,7 @@ class ResultsModel
public function getResultsById(int $idQuiz, int $idUser) : ?ResultsEntity
{
$res = $this -> gw -> findResultsById($idQuiz, $idUser);
$res = $this -> gateway -> findResultsById($idQuiz, $idUser);
if ($res)
{
@ -73,7 +68,7 @@ class ResultsModel
public function getAllResults() : array
{
$res = $this -> gw -> findAllResults();
$res = $this -> gateway -> findAllResults();
$results = [];
@ -91,6 +86,6 @@ class ResultsModel
public function updateResultsModel(int $idQuiz, int $idUser, ?int $score, ?int $time) : bool
{
return $this -> gw -> updateResults($idQuiz, $idUser, $score, $time);
return $this -> gateway -> updateResults($idQuiz, $idUser, $score, $time);
}
}

@ -2,14 +2,10 @@
namespace Model;
use Entity\Quote;
use Gateway\QuoteGateway;
use Gateway\Gateway;
class SearchModel
class SearchModel extends Model
{
private QuoteGateway $gateway;
public function __construct(QuoteGateway $gate){
$this->gateway = $gate;
}
public function searchQuote(?string $type,?string $search,array $filtre): array{

@ -3,14 +3,10 @@
use Entity\User;
use Entity\UserEntity;
use Gateway\UserGateway;
use Gateway\Gateway;
class UserModel
class UserModel extends Model
{
private UserGateway $gateway;
public function __construct(UserGateway $gate){
$this->gateway = $gate;
}
public function insertUser(string $username,string $email,string $passwd) : bool{
/*global $rep,$image;*/

@ -2,17 +2,11 @@
namespace Model;
use Entity\SourceEntity;
use Gateway\SourceGateway;
use Gateway\Gateway;
class SourceModel
class SourceModel extends Model
{
private sourceGateway $gateway;
public function __construct(SourceGateway $gateway)
{
$this -> gateway = $gateway;
}
public function createSource(int $id_source, string $title, string $date) : bool
{
$q = new SourceEntity($id_source , $title, $date);

Loading…
Cancel
Save