I have a problem related to Doctrine2:
1- I have two tables joining on a many-to-one relation:
Table 1 - Activity
The Schema:
Backend\adminBundle\Entity\Activity: type: entity table: activity indexes: result_id: columns: - result_id id: id: type: integer nullable: false unsigned: false comment: '' id: true generator: strategy: IDENTITY fields: ...... manyToOne: result: targetEntity: Actionresult cascade: { } mappedBy: null inversedBy: null joinColumns: result_id: referencedColumnName: id orphanRemoval: false The Entity
<?php namespace Backend\adminBundle\Entity; use Doctrine\ORM\Mapping as ORM; class Activity { /** * @var \Backend\adminBundle\Entity\Actionresult * * @ORM\ManyToOne(targetEntity="Backend\adminBundle\Entity\Actionresult") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="result_id", referencedColumnName="id") * }) */ private $result; /** * @var \Backend\adminBundle\Entity\SfGuardUser * * @ORM\ManyToOne(targetEntity="Backend\adminBundle\Entity\SfGuardUser") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="user_id", referencedColumnName="id") * }) */ /* There are other Properties */ /** * Set result * * @param \Backend\adminBundle\Entity\Actionresult $result * @return Activity */ public function setResult(\Backend\adminBundle\Entity\Actionresult $result = null) { $this->result = $result; return $this; } /** * Get result * * @return \Backend\adminBundle\Entity\Actionresult */ public function getResult() { return $this->result; } }
Table 2 - Actionresult Related to Activity Table by Id:
The schema:
Backend\adminBundle\Entity\Actionresult: type: entity table: actionresult id: id: type: integer nullable: false unsigned: false comment: '' id: true generator: strategy: IDENTITY fields: name: type: string nullable: false length: 255 fixed: false comment: '' lifecycleCallbacks: { } The Entity:
<?php namespace Backend\adminBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Actionresult * * @ORM\Table(name="actionresult") * @ORM\Entity */ class Actionresult { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var string * * @ORM\Column(name="name", type="string", length=255, nullable=false) */ private $name; /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set name * * @param string $name * @return Actionresult */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } } The Question:
With doctrine i can refer from table Activity to Actionresult with the name result.
How can i refer with doctrine from table Actionresult to Activity??
Thank you in advance.