createQueryBuilder(); $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('user', $studentId)); if ($showPrivate == false) { $criteria->andWhere(Criteria::expr()->eq('private', false)); } $pageSize = StudentFollowUpPlugin::getPageSize(); $qb ->select('p') ->distinct() ->from('ChamiloPluginBundle:StudentFollowUp\CarePost', 'p') ->addCriteria($criteria) ->setFirstResult($pageSize * ($currentPage - 1)) ->setMaxResults($pageSize) ->orderBy('p.createdAt', 'desc') ; $query = $qb->getQuery(); $posts = new Paginator($query, $fetchJoinCollection = true); $totalItems = count($posts); $pagesCount = ceil($totalItems / $pageSize); $pagination = ''; $url = api_get_self().'?student_id='.$studentId; if ($totalItems > 1) { $pagination .= '