diff --git a/index.php b/index.php index 9a38e78..d7b14a0 100644 --- a/index.php +++ b/index.php @@ -59,5 +59,13 @@ $projects = getProjects($page, $limit); + + diff --git a/lib/database.php b/lib/database.php index e21cca0..28625ab 100644 --- a/lib/database.php +++ b/lib/database.php @@ -1,5 +1,8 @@ prepare('select id, title, illustration, description, date from project limit :from, :limit'); - + $query->bindParam(':from', $from, PDO::PARAM_INT); $query->bindParam(':limit', $limit, PDO::PARAM_INT); @@ -24,7 +31,13 @@ function getProjects($page = 1, $limit = 5) return $query->fetchAll(); } -function getProject($id) +/** + * Retourne un projet en fonction de son id + * + * @param int $id id du projet + * @return array|false Le projet + */ +function getProject($id) { if (!is_integer($id)) { throw new InvalidArgumentException('The argument "id" must be an interger.'); @@ -33,7 +46,7 @@ function getProject($id) $pdo = getDatabaseConnection(); $query = $pdo->prepare('select id, title, illustration, description, date from project where id=:id'); - + $query->bindParam(':id', $id, PDO::PARAM_INT); $query->execute(); @@ -41,12 +54,16 @@ function getProject($id) return $query->fetch(); } -function getProjectNumberOfPages($maxPerPage) +/** + * @param int $maxPerPage Nombre de projets par page + * @return int Le nombre de pages + */ +function getProjectNumberOfPages($maxPerPage) { if (!is_integer($maxPerPage)) { throw new InvalidArgumentException('The argument "maxPerPage" must be an interger.'); } - + $pdo = getDatabaseConnection(); $query = $pdo->prepare('select count(*) as total from project'); @@ -58,7 +75,13 @@ function getProjectNumberOfPages($maxPerPage) return ceil($result['total'] / $maxPerPage); } -function getCommentsByProject($id) +/** + * Returne les commentaires d'un projet + * + * @param int $id L'id du projet + * @return array Les commentaire du projet + */ +function getCommentsByProject($id) { // À réaliser }