ADD : skin and games methods
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
fb0d6ec69a
commit
5c0ad12fd9
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
require_once('model/game.php');
|
||||
|
||||
class GameGateway{
|
||||
|
||||
private $connecion;
|
||||
|
||||
// Constructor
|
||||
public function __construct($_connection){
|
||||
$this->connection=$_connection;
|
||||
}
|
||||
|
||||
/* Functions implemented to manage games' data from database
|
||||
* getGames : returning all the games found in database
|
||||
* getGameById : returning a game found in database with its id
|
||||
*/
|
||||
|
||||
/// Brief : Returning all the games found in database
|
||||
public function getGames():?array{
|
||||
$tabGames=null;
|
||||
$query="SELECT * FROM Game";
|
||||
$this->connection->execQuery($query,[]);
|
||||
$res = $this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
$tabGames[]= new Game($row['id'],$row['name'],$row['image']);
|
||||
}
|
||||
return $tabGames;
|
||||
}
|
||||
|
||||
/// Brief : Returning a game found in database with its id
|
||||
/// Parameters : * $id (string): identifier of the game we are looking for
|
||||
public function getGameById(string $id):?Game{
|
||||
$game=null;
|
||||
$query="SELECT * FROM Game WHERE id=:id";
|
||||
$arg=array('id'=>array($id,PDO::PARAM_STR));
|
||||
$this->connection->execQuery($query,$arg);
|
||||
$res=$this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
$game= new Game($row['id'],$row['name'],$row['image']);
|
||||
}
|
||||
return $game;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
require_once('model/skin.php');
|
||||
|
||||
class SkinGateway{
|
||||
|
||||
private $connection;
|
||||
|
||||
public function __construct($_connection){
|
||||
$this->connection=$_connection;
|
||||
}
|
||||
|
||||
/* Functions implemented to manage skins' data from database
|
||||
* getGames : returning all the skins found in database
|
||||
* getGameById : returning a skin found in database with its id
|
||||
*/
|
||||
|
||||
/// Brief : Returning all the skins found in database
|
||||
public function getSkins():?array{
|
||||
$tabSkins=null;
|
||||
$query="SELECT * FROM Skin";
|
||||
$this->connection->execQuery($query,[]);
|
||||
$res = $this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
$tabSkins[]= new Game($row['id'],$row['name'],$row['image']);
|
||||
}
|
||||
return $tabSkins;
|
||||
}
|
||||
|
||||
/// Brief : Returning a skin found in database with its id
|
||||
/// Parameters : * $id (string): identifier of the skin we are looking for
|
||||
public function getSkinById(string $id):?Game{
|
||||
$skin=null;
|
||||
$query="SELECT * FROM Skin WHERE id=:id";
|
||||
$arg=array('id'=>array($id,PDO::PARAM_STR));
|
||||
$this->connection->execQuery($query,$arg);
|
||||
$res=$this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
$skin= new Game($row['id'],$row['name'],$row['image']);
|
||||
}
|
||||
return $skin;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
class Game{
|
||||
public string $id;
|
||||
public string $name;
|
||||
public string $image;
|
||||
|
||||
|
||||
public function __construct(string $_id, string $_name, string $_image){
|
||||
$this->id=$_id;
|
||||
$this->name=$_name;
|
||||
$this->image=$_image;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class Skin{
|
||||
|
||||
public string $id;
|
||||
public string $name;
|
||||
public string $image;
|
||||
|
||||
public function __construct(string $_id, string $_name, string $_image){
|
||||
$this->id=$_id;
|
||||
$this->name=$_name;
|
||||
$this->image=$_image;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in new issue