Skip to content

Instantly share code, notes, and snippets.

@AaronDDM
Created June 16, 2011 17:29
Show Gist options
  • Save AaronDDM/8a5b071fa6c9cbda4ae7 to your computer and use it in GitHub Desktop.
Save AaronDDM/8a5b071fa6c9cbda4ae7 to your computer and use it in GitHub Desktop.
Two entities
<?php
namespace myProject\Entity;
Class Address {
/**
* @ORM\Id
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $postalCode;
public function getPostalCode()
{
return $this->postalCode;
}
public function setPostalCode($postalCode)
{
$this->postalCode= $postalCode;
}
}
<?php
namespace myProject\Entity;
use myProject\Entity\Address;
Class User {
/**
* @ORM\Id
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $name;
/**
* @ORM\OneToOne(targetEntity="Address")
* @ORM\JoinColumn(name="id", referencedColumnName="id")
*/
protected $address;
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getAddress()
{
return $this->address;
}
public function setAddress(Address $address)
{
$this->address = $address;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment