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.
WF-Website/src/Gateway/commentaryGateway.php

56 lines
1.6 KiB

<?php
namespace Gateway;
namespace Gateway;
use Connection;
use PDO;
class CommentaryGateway {
private Connection $co ;
public function __construct(Connection $co) {
$this->co = $co;
}
public function create(commentaryEntity $c) :bool {
$query="INSERT INTO Commentary VALUES(:id_comment, :comment , :date)";
return $this -> co -> executeQuery($query, array(
"id_comment" => array($c->getIdComment(), PDO::PARAM_INT),
"comment" => array($c->getComment(), PDO::PARAM_STR),
"date" => array($c->getDate(), PDO::PARAM_STR)));
}
public function findById(int $id) : ?commentaryEntity {
$query="SELECT * FROM Commentary WHERE id_comment = :id_comment";
$this -> co -> executeQuery($query, array("id_comment" => $id));
return $res = $this -> co -> getResults();
}
public function findAll() : array {
$query="SELECT * FROM Commentary";
$this -> co -> executeQuery($query);
return $res = $this -> co -> getResults();
}
public function delete(int $id) : bool {
$query="DELETE FROM Commentary WHERE id_comment = :id_comment";
return $this -> co -> executeQuery($query, array("id_comment" => $id));
}
public function update(commentaryEntity $c) : bool {
$query="UPDATE Commentary SET comment = :comment WHERE id_comment = :id_comment";
return $this -> co -> executeQuery($query, array(
"comment" => array($c->getComment(),PDO::PARAM_STR),
"id_comment" => array($c->getIdComment(),PDO::PARAM_INT))
);
}
}