Answer the question
In order to leave comments, you need to log in
Entity inheritance via Superclass in Doctrine 2, why are fields copied to descendants?
Good afternoon everyone!
Understanding inheritance in Doctrine 2 as described here.
I create a class:
use Doctrine\ORM\Mapping as ORM;<br><br>
/**<br>
*<br>
* @ORM\MappedSuperclass<br>
*/<br>
abstract class AbstractEntity<br>
{<br>
/**<br>
* @var User<br>
* @ORM\ManyToOne(targetEntity="User")<br>
* @ORM\JoinColumn(name="user_created_id", referencedColumnName="id")<br>
*/<br>
protected $userCreated;<br><br>
/**<br>
* Set userCreated<br>
*<br>
* @param User $userCreated<br>
* @return AbstractEntity<br>
*/<br>
public function setUserCreated(User $userCreated = null)<br>
{<br>
$this->userCreated = $userCreated;<br>
return $this;<br>
}<br><br>
/**<br>
* Get userCreated<br>
*<br>
* @return User<br>
*/<br>
public function getUserCreated()<br>
{<br>
return $this->userCreated;<br>
}<br>
}<br>
/**<br>
* @ORM\Entity<br>
*/<br>
class Record extends AbstractEntity {<br>
/**<br>
* @ORM\Id<br>
* @ORM\Column(name="id", type="integer")<br>
* @var integer<br>
*/<br>
protected $id;<br>
}<br>
php app/console doctrine:generate:entities NAMESPACE
Answer the question
In order to leave comments, you need to log in
Execution doctrine:generate:entities
should be generally avoided. This command is only used to start and allows you to convert an existing database structure into entities. In the future, entities need to be ruled only by hands.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question