Created
April 15, 2017 20:57
-
-
Save Digi92/568d1024ecab520554aed21b4578c972 to your computer and use it in GitHub Desktop.
Doctrine
Beispiel zum Erstellen einer Base Entity Klasse so das alle anderen Klassen die diese Extenden die Felder auch in der Datenbank bekommen. Die Base Entity Klasse benötigt nur "@Orm\MappedSuperclass" als Annotation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace AppBundle\Entity; | |
| use Doctrine\ORM\Mapping as ORM; | |
| /** | |
| * Class BaseEntity | |
| * @package AppBundle\Entity | |
| * @ORM\MappedSuperclass | |
| */ | |
| class BaseEntity | |
| { | |
| /** | |
| * @ORM\Column(type="integer") | |
| * @ORM\Id | |
| * @ORM\GeneratedValue(strategy="AUTO") | |
| * @var integer | |
| */ | |
| private $id; | |
| /** | |
| * Get id | |
| * | |
| * @return integer | |
| */ | |
| public function getId() | |
| { | |
| return $this->id; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace AppBundle\Entity; | |
| use Doctrine\ORM\Mapping as ORM; | |
| /** | |
| * Class ChildEntity | |
| * @package AppBundle\Entity | |
| * @ORM\Entity | |
| * @ORM\Table(name="child_entity") | |
| */ | |
| class ChildEntity extends BaseEntity | |
| { | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment