Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* setup.php zum Erzeugen des Datenbank-Schemas hinzugefügt
* Erstes Modell Person erzeugt
- Loading branch information
Marc Remolt
committed
Jun 21, 2010
1 parent
8d573b6
commit a5dd997
Showing
4 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
namespace Models; | ||
|
||
/** | ||
* @Entity | ||
* @Table(name="personen") | ||
*/ | ||
class Person | ||
{ | ||
/** | ||
* @Id @Column(type="integer") | ||
* @GeneratedValue | ||
*/ | ||
private $id; | ||
/** @Column(type="string") */ | ||
private $vorname; | ||
/** @Column(type="string") */ | ||
private $nachname; | ||
/** @Column(type="date", nullable=true) */ | ||
private $geburtstag; | ||
/** @Column(type="decimal", nullable=true) */ | ||
private $gewicht; | ||
|
||
public function getId() { | ||
return $this->id; | ||
} | ||
|
||
public function getVorname() { | ||
return $this->vorname; | ||
} | ||
|
||
public function setVorname($vorname) { | ||
$this->vorname = $vorname; | ||
return $this; | ||
} | ||
|
||
public function getNachname() { | ||
return $this->nachname; | ||
} | ||
|
||
public function setNachname($nachname) { | ||
$this->nachname = $nachname; | ||
return $this; | ||
} | ||
|
||
public function getGeburtstag() { | ||
return $this->geburtstag; | ||
} | ||
|
||
public function setGeburtstag(\DateTime $geburtstag) { | ||
$this->geburtstag = $geburtstag; | ||
return $this; | ||
} | ||
|
||
public function getGewicht() { | ||
return $this->gewicht; | ||
} | ||
|
||
public function setGewicht($gewicht) { | ||
$this->gewicht = $gewicht; | ||
return $this; | ||
} | ||
|
||
public function __toString() { | ||
return $this->getVorname() . ' ' . $this->getNachname() | ||
. ' (' . $this->getId() . ')'; | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
<?php | ||
require_once 'config.inc.php'; | ||
|
||
var_dump($em); | ||
use Models\Person; | ||
|
||
$p1 = new Person(); | ||
|
||
$p1->setVorname('Arthur') | ||
->setNachName('Dent') | ||
->setGeburtstag(new DateTime('1968-08-25')) | ||
->setGewicht(83); | ||
|
||
$em->persist($p1); | ||
$em->flush(); | ||
|
||
echo $p1; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
require_once 'config.inc.php'; | ||
|
||
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em); | ||
$metadata = $em->getMetadataFactory()->getAllMetadata(); | ||
|
||
$schemaTool->updateSchema($metadata); |