This commit is contained in:
Simon Vieille 2016-01-28 12:06:35 +01:00
parent 672ca49046
commit 402595a678
2 changed files with 37 additions and 1 deletions

View File

@ -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

View File

@ -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);
?>