comments
This commit is contained in:
parent
672ca49046
commit
402595a678
|
@ -86,7 +86,34 @@ function getCommentsByProject($id)
|
|||
// À réaliser
|
||||
}
|
||||
|
||||
// Prévoir une fonction pour enregistrer un commentaire
|
||||
/**
|
||||
* Enregistre un nouveau commentaire
|
||||
*
|
||||
* @param string $name Nom de l'auteur
|
||||
* @param string $email Email de l'auteur
|
||||
* @param string $website Site web de l'auteur
|
||||
* @param string $content Contenu du commentaire
|
||||
* @param DateTime $date Date du commentaire
|
||||
* @param int $projectId L'id du projet associé
|
||||
*/
|
||||
function createComment($name, $email, $website, $content, DateTime $date, $projectId)
|
||||
{
|
||||
$pdo = getDatabaseConnection();
|
||||
|
||||
$query = $pdo->prepare(
|
||||
'insert into comment(name, email, website, content, date, project_id)
|
||||
value(:name, :email, :website, :content, :date, :project_id)'
|
||||
);
|
||||
|
||||
$query->execute([
|
||||
':name' => $name,
|
||||
':email' => $email,
|
||||
':website' => $website,
|
||||
':content' => $content,
|
||||
':date' => $date->format('Y-m-d H:i:s'),
|
||||
':project_id' => $projectId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Génère et retourne une pagination
|
||||
|
|
|
@ -17,6 +17,15 @@ if (false === $project) {
|
|||
die;
|
||||
}
|
||||
|
||||
// createComment(
|
||||
// 'Simon',
|
||||
// 'simon@deblan.fr',
|
||||
// 'https://www.deblan.io/',
|
||||
// 'Mon second super commentaire !',
|
||||
// new DateTime('now'),
|
||||
// $id
|
||||
// );
|
||||
|
||||
$comments = getCommentsByProject($id);
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue