Note that there are some explanatory texts on larger screens.

plurals
  1. PODoctrine creating useless join table
    primarykey
    data
    text
    <p>so, i have two entities: <code>Genre</code> and <code>Game</code></p> <p><strong>Genre.php</strong></p> <pre><code>&lt;?php namespace Acme\Bundle\DemoBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; /** * Genre * * @ORM\Table(name="genre") * @ORM\Entity */ class Genre { /** * @var integer * * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ protected $id; /** * @var string * * @ORM\Column(name="name", type="string", length=64, nullable=false) */ protected $name; /** * @var string * * @ORM\Column(name="display", type="string", length=64, nullable=false) */ protected $display; /** * @var string * * @ORM\Column(name="description", type="text", nullable=false) */ protected $description; /** * @var ArrayCollection|Game[] * * @ORM\ManyToMany(targetEntity="Game", inversedBy="genres", cascade={"persist"}) */ protected $games; // ... Irrelevant Constructor and following getters/setters } </code></pre> <p><strong>Game.php</strong></p> <pre><code>&lt;?php namespace Acme\Bundle\DemoBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; /** * Game * * @ORM\Table(name="game") * @ORM\Entity */ class Game { /** * @var integer * * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ protected $id; /** * @var string * * @ORM\Column(name="name", type="string", length=256, nullable=false) */ protected $name; /** * @var string * * @ORM\Column(name="display", type="string", length=256, nullable=false) */ protected $display; /** * @var string * * @ORM\Column(name="description", type="text", nullable=false) */ protected $description; /** * @var ArrayCollection|Genre[] * * @ORM\ManyToMany(targetEntity="Genre", inversedBy="games", cascade={"persist"}) * @ORM\JoinTable(name="genre_game", * joinColumns={@ORM\JoinColumn(name="genre_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="game_id", referencedColumnName="id")} * ) */ protected $genres; /** * @var ArrayCollection|Platform[] * * @ORM\ManyToMany(targetEntity="Platform", inversedBy="games", cascade={"persist"}) * @ORM\JoinTable(name="platform_game", * joinColumns={@ORM\JoinColumn(name="platform_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="game_id", referencedColumnName="id")} * ) */ protected $platforms; /** * @var Image[] * * @ORM\OneToMany(targetEntity="Image",mappedBy="game_id", cascade={"persist"}) */ protected $images; } </code></pre> <p>When i run <code>php app/console doctrine:schema:create</code> or <code>update</code>, it creates all of the needed join tables I specified above, but it also creates <strong><code>genre_genre</code></strong></p> <p>This table is always empty, and doesnt seem to do anything, and prevents me from running <code>php app/console doctrine:schema:update</code>'s later, and its trying to add an index to it that already exists</p> <p>Anyone see what I'm doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload