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/models/commentaryModel.php

42 lines
1.0 KiB

<?php
require_once "commentaryEntity.php";
require_once "commentaryGateway.php";
class CommentaryModel {
private commentaryGateway $gw;
function __construct(commentaryGateway $gw) {
$this->gw = $gw;
}
public function createComment(int $id_comment, string $comment, string $date): bool {
$c = new CommentaryEntity($id_comment, $comment, $date);
return $this->gw->create($c);
}
public function getComment(int $id_comment): ?commentaryEntity {
return $this -> gw -> findById($id_comment);
}
public function getComments(): array {
return $this -> gw -> findAll();
}
public function deleteComment(int $id_comment): bool {
return $this -> gw -> delete($id_comment);
}
public function updateComment(int $id_comment, string $comment): bool {
$c = $this -> gw -> findById($id_comment);
if($c){
$c -> setComment($comment);
return $this->gw -> update($c);
}
return false;
}
}