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 {
private $id;
/** @Column(type="string", length=255) */
private $street;
/** @OneToOne(targetEntity="User", mappedBy="address") */
/** @OneToOne(targetEntity="User", mappedBy="address", cascade={"persist"}) */
private $user;
public function getId() {
......
......@@ -15,9 +15,20 @@ class User {
private $test;
/**
* @OneToOne(targetEntity="Address")
* @JoinColumn(name="address_id", referencedColumnName="id")
* @JoinColumns({
* @JoinColumn(name="address_id", referencedColumnName="id"),
* @JoinColumn(name="address2_id", referencedColumnName="id")
* })
*/
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() {
return $this->id;
......
......@@ -23,8 +23,10 @@ $config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$connectionOptions = array(
'driver' => 'pdo_sqlite',
'path' => 'database.sqlite'
'driver' => 'pdo_mysql',
'user' => 'root',
'password' => '',
'dbname' => 'doctrine2'
);
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
......
......@@ -14,7 +14,7 @@ $classLoader->register();
// Set up caches
$config = new \Doctrine\ORM\Configuration;
$cache = new \Doctrine\Common\Cache\ApcCache;
$cache = new \Doctrine\Common\Cache\ArrayCache;
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
......@@ -30,6 +30,13 @@ $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
## PUT YOUR TEST CODE BELOW
$user = new User;
$user->setName('jwage');
$address = new Address;
$address->setStreet('6512 Mercomatic Court');
$address->setUser($user);
$user->setAddress($address);
echo "Hello World!";
\ No newline at end of file
$em->persist($user);
$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