->where('e.isRead = 0')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->andWhere('e.isDeleted=0')
+ ->orderBy('e.createdAt', 'desc')
->getQuery();
$paginator = new Paginator($qb);
->where('e.isRead = 1')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->andWhere('e.isDeleted=0')
+ ->orderBy('e.createdAt', 'desc')
->getQuery();
$paginator = new Paginator($qb);
->where('e.isFav = 1')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->andWhere('e.isDeleted=0')
+ ->orderBy('e.createdAt', 'desc')
->getQuery();
$paginator = new Paginator($qb);
public function findEntries($userId, $isArchived, $isStarred, $isDeleted, $sort, $order)
{
- //TODO tous les paramètres ne sont pas utilisés, à corriger
$qb = $this->createQueryBuilder('e')
->select('e')
->where('e.userId =:userId')->setParameter('userId', $userId);
$qb->andWhere('e.isDeleted =:isDeleted')->setParameter('isDeleted', $isDeleted);
}
+ if ('created' === $sort) {
+ $qb->orderBy('e.createdAt', $order);
+ } elseif ('updated' === $sort) {
+ $qb->orderBy('e.updatedAt', $order);
+ }
+
return $qb
->getQuery()
->getResult(Query::HYDRATE_ARRAY);