Commit 204b6d71 authored by jwage's avatar jwage

[2.0] Finishing the AnnotationExporter to export relationships properly

parent aba096cc
...@@ -11,7 +11,7 @@ class Address { ...@@ -11,7 +11,7 @@ class Address {
private $id; private $id;
/** @Column(type="string", length=255) */ /** @Column(type="string", length=255) */
private $street; private $street;
/** @OneToOne(targetEntity="User", mappedBy="address") */ /** @OneToOne(targetEntity="User", mappedBy="address", cascade={"persist"}) */
private $user; private $user;
public function getId() { public function getId() {
......
...@@ -15,9 +15,20 @@ class User { ...@@ -15,9 +15,20 @@ class User {
private $test; private $test;
/** /**
* @OneToOne(targetEntity="Address") * @OneToOne(targetEntity="Address")
* @JoinColumn(name="address_id", referencedColumnName="id") * @JoinColumns({
* @JoinColumn(name="address_id", referencedColumnName="id"),
* @JoinColumn(name="address2_id", referencedColumnName="id")
* })
*/ */
private $address; private $address;
/**
* @ManyToMany(targetEntity="Group")
* @JoinTable(name="user_group",
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")
* })
*/
private $groups;
public function getId() { public function getId() {
return $this->id; return $this->id;
......
...@@ -23,8 +23,10 @@ $config = new \Doctrine\ORM\Configuration(); ...@@ -23,8 +23,10 @@ $config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$connectionOptions = array( $connectionOptions = array(
'driver' => 'pdo_sqlite', 'driver' => 'pdo_mysql',
'path' => 'database.sqlite' 'user' => 'root',
'password' => '',
'dbname' => 'doctrine2'
); );
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
......
...@@ -14,7 +14,7 @@ $classLoader->register(); ...@@ -14,7 +14,7 @@ $classLoader->register();
// Set up caches // Set up caches
$config = new \Doctrine\ORM\Configuration; $config = new \Doctrine\ORM\Configuration;
$cache = new \Doctrine\Common\Cache\ApcCache; $cache = new \Doctrine\Common\Cache\ArrayCache;
$config->setMetadataCacheImpl($cache); $config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache); $config->setQueryCacheImpl($cache);
...@@ -30,6 +30,13 @@ $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); ...@@ -30,6 +30,13 @@ $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
## PUT YOUR TEST CODE BELOW ## PUT YOUR TEST CODE BELOW
$user = new User; $user = new User;
$user->setName('jwage');
$address = new Address; $address = new Address;
$address->setStreet('6512 Mercomatic Court');
$address->setUser($user);
$user->setAddress($address);
echo "Hello World!"; $em->persist($user);
\ No newline at end of file $em->persist($address);
$em->flush();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment