order by dans la récupération des projets
This commit is contained in:
parent
de10cce572
commit
2fdf0be324
|
@ -7,7 +7,7 @@
|
|||
* @param int $limit Nombre de projets par page
|
||||
* @return array Les projets
|
||||
*/
|
||||
function getProjects($page = 1, $limit = 5)
|
||||
function getProjects($page = 1, $limit = 5, $orderBy = 'date', $orderBySens = 'ASC')
|
||||
{
|
||||
if (!is_integer($page)) {
|
||||
throw new InvalidArgumentException('The argument "page" must be an integer.');
|
||||
|
@ -21,7 +21,17 @@ function getProjects($page = 1, $limit = 5)
|
|||
|
||||
$pdo = getDatabaseConnection();
|
||||
|
||||
$query = $pdo->prepare('select id, title, illustration, description, date from project limit :from, :limit');
|
||||
$query = $pdo->prepare(
|
||||
'
|
||||
select
|
||||
id, title, illustration, description, date
|
||||
from
|
||||
project
|
||||
order by
|
||||
'.$orderBy.' '.$orderBySens.'
|
||||
limit
|
||||
:from, :limit'
|
||||
);
|
||||
|
||||
$query->bindParam(':from', $from, PDO::PARAM_INT);
|
||||
$query->bindParam(':limit', $limit, PDO::PARAM_INT);
|
||||
|
|
Loading…
Reference in a new issue