1

Can you explain me please, how to index Doctrine entity collections? I have an entity Article with collection of related Categories defined as @ManyToMany relationship. In this annotation I have parameter indexBy="id" which I hope creates an array of Categories indexed by its IDs. But the Categories collection is indexed like an php array from 0. The code looks like:

    /**
     * @ORM\ManyToMany(targetEntity="Category", inversedBy="articles", indexBy="id", cascade={"persist", "remove"})
     * @ORM\JoinTable(name="articles_categories")
     */
    private $categories;

Can you tell me what am I doing wrong? THX.

Čamo
  • 3,863
  • 13
  • 62
  • 114

0 Answers0