2

I'm having trouble with a Doctrine 2 mapped superclass, to define a ManyToMany Relation.

My code is :

use Doctrine\Common\Collections\ArrayCollection;

/** @MappedSuperclass */
abstract class MyAbstractClassA
{
    /**
     * @Id
     * @GeneratedValue
     * @Column(type="integer")
     * @var int
     */
    protected $id;

    /**
     * @ManyToMany(targetEntity="MyClassE")
     * @var MyClassE[]
     */
    protected $my_class_es;

    // ... Other fields and methods
}

/** @Entity() */
class MyConcreteClassAa extends MyAbstractClassA
{
    /**
     * @Column(type="string")
     * @var string
     */
    public $aa_param;

    // ... Other fields and methods
}

/** @Entity() */
class MyConcreteClassAb extends MyAbstractClassA
{
    /**
     * @Column(type="string")
     * @var string
     */
    public $ab_param;

    // ... Other fields and methods
}

/** @Entity() */
class MyClassE
{
    /**
     * @Id
     * @Column(type="integer")
     * @var int
     */
    protected $id;

    /**
     * @Column(type="string")
     * @var string
     */
    protected $e_param;

    /**
     * @ManyToOne(targetEntity="MyClassF")
     * @var MyClassF
     */
    protected $my_class_f;

    // ... Other fields and methods
}

/** @Entity() */
class MyClassF
{
    /**
     * @Id
     * @Column(type="integer")
     * @var int
     */
    protected $id;

    // ... Other fields and methods
}

So here is the schema of what i have : http://pix.toile-libre.org/upload/original/1385651287.png And there is what i want : http://pix.toile-libre.org/upload/original/1385651300.png

I don't know how to obtain this result, could someone tell me if it's possible ?

Thank you for helping me.

ena
  • 85
  • 7
  • It does not make sense: `Column=integer - Var=string` I never worked with abstract entities but doctrine is generating proxy classes to use `find()`, `findBy()`,.. and you need mutator methods like `MyConcreteClassAa::addMyClassE(MyClassF)`, `removeMyClassE()`, `setMyClassE(ArrayCollection)`, `getMyClassE()`. Your Classnames and properties are very hard to follow, give it real world names like `Teacher` `Students`.. – Daniel W. Nov 28 '13 at 15:06
  • Yeah, i noticed that just after posting, i've just edited it. Thank you for your quick answer :) – ena Nov 28 '13 at 15:11

0 Answers0