Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere-ing in discriminated tables
    text
    copied!<p>How can I select all items from one specific author ? Its possible this way ? Or how can I edit entities if I want many item types and item packages (item has many items) too ?</p> <p>Item</p> <pre><code>/** * @ORM\Table() * @ORM\Entity * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="discr", type="string") * @ORM\DiscriminatorMap({ * "cd" = "ItemCD", * "dvd" = "ItemDVD", * "pack" = "ItemPack", * }) */ class Item { /** * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @ORM\Column(name="name", type="string", length=250, nullable=false) */ private $name; } </code></pre> <p>ItemCD</p> <pre><code>/** * @ORM\Table() * @ORM\Entity */ class ItemCD extends Item { /** * @ORM\ManyToOne(targetEntity="Author", inversedBy="item") * @ORM\JoinColumn(name="author_id", referencedColumnName="id") */ private $author; } </code></pre> <p>ItemDVD</p> <pre><code>/** * @ORM\Table() * @ORM\Entity */ class ItemDVD extends Item { /** * @ORM\ManyToOne(targetEntity="Author", inversedBy="item") * @ORM\JoinColumn(name="author_id", referencedColumnName="id") */ private $author; } </code></pre> <p>ItemPack</p> <pre><code>/** * @ORM\Table() * @ORM\Entity */ class ItemPack extends Item { /** * @ORM\ManyToMany(targetEntity="Item", inversedBy="item") * @ORM\JoinTable() */ private $items; } </code></pre> <p>Author</p> <pre><code>/** * @ORM\Table() * @ORM\Entity */ class Author { /** * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") * */ private $id; /** * @ORM\Column(name="name", type="string", length=250, nullable=false) */ private $name; } </code></pre>
 

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