I would like to paginate a complex request with at least 2 left joins, but the pagination bundle I'm using (KnpPaginationBundle) can't tell Doctrine how to count the result (which is needed for the pagination process), and keep having this Exception. Cannot count query which selects two FROM components, cannot make distinction 500 Internal Server Error - RuntimeException
$em = $this->getDoctrine()->getManager();
$user = $this->container->get('security.context')->getToken()->getUser();
$user->getId();
$dql = "SELECT o FROM DefaultBundle:Offer o ,DefaultBundle:FavoriteOffer fo WHERE fo.offerid=o.id and fo.userid =".$user->getId();
$query = $em->createQuery($dql);
$paginator = $this->get('knp_paginator');
$table = $paginator->paginate($query, $request->query->getInt('page', 1), 10);
Any idea on how to paginate over a complex request thanks.
Favorite offer
class FavoriteOffer
{
/**
* @var \Offer
*
* @ORM\ManyToOne(targetEntity="Offer")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="Offerid", referencedColumnName="id")
* })
*/
private $offerid;
/**
* @var \User
*
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="Userid", referencedColumnName="id")
* })
*/
private $userid;