2

I have 3 Entities in doctrine:

Listitem:

class Listitem
{

/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue()
 */
protected $id;

...
}

Item:

class Item
{

/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue()
 */
protected $id;

...
}

and ListitemOrder

/**
 * Class ListitemOrder
 * @package AppBundle\Entity
 * @ORM\Table(name="listitem_order",uniqueConstraints={@ORM\UniqueConstraint(name="uq_listitem_item", columns={"listitem_id", "item_id"})})
 * @ORM\Entity(repositoryClass="AppBundle\Repositories\ListitemOrderRepository")
 */
class ListitemOrder
{


/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue()
 */
 protected $id;

/**
 * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Listitem")
 */
protected $listitem;

/**
 * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Item")
 */
protected $item;

/**
 * @ORM\Column(type="integer")
 */
protected $order;
...
}

My lists have items, but it's possible that the items belong to other list, in diferent order. Because that I need the ListitemOrder entity.

When i want to get the items ordered of one list, I have one query like that:

$qb->select(array('l', 'i'))
        ->from('AppBundle:ListitemOrder', 'l')
        ->leftJoin("l.item", 'i')
        ->where('l.listitem = :listitem')->setParameter("listitem", $listitem)
        ->orderBy("l.order", 'DESC')
    ;

I think that this is correct, but when I want call this function, my browser and my vagrant vm dies. I think that it's happend because Doctrine get the informacion recursively and never ends. I mean, Item information, and the List, and the Items of the list, and the list of the items... It's possible?

The query generated is like this:

SELECT l0_.id AS id0, l0_.order AS order1, l0_.listitem_id AS listitem_id2, l0_.item_id AS item_id3 
FROM listitem_order l0_ 
LEFT JOIN item i1_ ON l0_.item_id = i1_.id 
WHERE l0_.listitem_id = 1 
ORDER BY l0_.order DESC 
LIMIT 25 OFFSET 0
Carlos Vázquez
  • 388
  • 1
  • 5
  • 17
  • 2
    possible duplicate of [Too much data with var\_dump in symfony2 doctrine2](http://stackoverflow.com/questions/11902099/too-much-data-with-var-dump-in-symfony2-doctrine2) – M Khalid Junaid Aug 20 '15 at 05:58
  • It's not the same. If I don't call `var_dump`, the browser crash too. The problem is -I think- in the structure of the relations in `ListitemOrder`entity. – Carlos Vázquez Aug 20 '15 at 22:43

0 Answers0