Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Finally i found the solution :)</p> <p>I had to create 2 more classes as my model. This classes should have all mapping Database and shoud be declared as single inheritance like this:</p> <pre><code>#src\Myproject\MYBUNDLE\Model\Menu /** * @ORM\Entity * @ORM\InheritanceType("SINGLE_TABLE") * @ORM\DiscriminatorColumn(name="discr", type="string") * @ORM\DiscriminatorMap({"menu1" = "Myproject\MYBUNDLE\Entity\Menu", "menu2" = "Menu"}) */ abstract class Menu { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; // Other fields } </code></pre> <p>That you should do with both entities (Menu and Group). The advantage of this implementation is that you don't lose any associations as before, due to declare them as mappedSuperClasss.</p> <p>Then you should declare one entity per each model class and declare them as MappedSuperClass. They should look like this:</p> <pre><code>#src\Myproject\MYBUNDLE\Entity\Menu use Doctrine\ORM\Mapping as ORM; use Tixpro\TMenuBundle\Model\Menu as BaseMenu; /** @ORM\MappedSuperclass */ class Menu extends BaseMenu { } </code></pre> <p>With this implementation you make sure not to lose any association. In addition, any entity could extend from your entities class to add more fields and customize them. For instance:</p> <pre><code>#src\Project\ChildBundle\Entity\Menu use Myproject\MYBUNDLE\Entity\Menu as TMenu; /** * @ORM\Entity * @ORM\Table(name="sf_menu") */ class Menu extends TMenu{ //put your code here } </code></pre> <p>Don't forget to configure the params in the config.yml to use MYBUNDLE. </p> <pre><code>mybundle: menu_entity: name: MyprojectChildBundle\Entity\Menu group_entity: name: MyprojectChildBundle\Entity\Group </code></pre> <p>if you dont do this, you couldn't know the repository inside MYBUNDLE and consequently you couldn't make joined queries into your MYBUNDLE. </p> <p>Finally, after setting your params and making that implementation, you are able to use joined queries inside your MYBUNDLE, like this:</p> <pre><code>$repo = $this-&gt;em-&gt;getRepository("MyprojectChildBundle:Menu"); $result = $repo-&gt;createQueryBuilder("wa") -&gt;select('wa, da') -&gt;join("wa.roles", "da") </code></pre> <p>That's all.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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