Commentaire et travail à réaliser

This commit is contained in:
Simon Vieille 2016-01-27 13:23:07 +01:00
parent 66f7fca498
commit 195282e4f2
3 changed files with 42 additions and 8 deletions

View file

@ -59,5 +59,13 @@ $projects = getProjects($page, $limit);
</article>
<?php endforeach ?>
</section>
<!--
Générer la pagination :
Première page | Précédent | 1 | 2 | 3 ... | Suivant | Dernière page
Mettre en avant la page courrante
-->
</body>
</html>

View file

@ -1,5 +1,8 @@
<?php
/**
* @return PDO Une instance PDO
*/
function getDatabaseConnection()
{
static $pdo;

View file

@ -1,5 +1,12 @@
<?php
/**
* Retourne une liste de projets en fonction d'une pagination
*
* @param int $page La page courrante
* @param int $limit Nombre de projet par page
* @return array Les projets
*/
function getProjects($page = 1, $limit = 5)
{
if (!is_integer($page)) {
@ -24,6 +31,12 @@ function getProjects($page = 1, $limit = 5)
return $query->fetchAll();
}
/**
* 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)) {
@ -41,6 +54,10 @@ function getProject($id)
return $query->fetch();
}
/**
* @param int $maxPerPage Nombre de projets par page
* @return int Le nombre de pages
*/
function getProjectNumberOfPages($maxPerPage)
{
if (!is_integer($maxPerPage)) {
@ -58,6 +75,12 @@ function getProjectNumberOfPages($maxPerPage)
return ceil($result['total'] / $maxPerPage);
}
/**
* Returne les commentaires d'un projet
*
* @param int $id L'id du projet
* @return array Les commentaire du projet
*/
function getCommentsByProject($id)
{
// À réaliser