Skip to content

Instantly share code, notes, and snippets.

@JiNexus
Last active April 8, 2019 01:38
Show Gist options
  • Save JiNexus/d843f67ed3cdd19672dbbb4ec16e876d to your computer and use it in GitHub Desktop.
Save JiNexus/d843f67ed3cdd19672dbbb4ec16e876d to your computer and use it in GitHub Desktop.
Doctrine Unidirectional Association Sample 2
<?php
namespace System\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class User
* @package System\Entity
* @ORM\Entity()
* @ORM\Table(name="`user`")
*/
class User
{
/**
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(name="id", type="bigint", options={"unsigned":true})
*/
private $id;
/**
* @ORM\OneToOne(targetEntity="System\Entity\UserInformation")
* @ORM\JoinColumn(name="user_information_id", referencedColumnName="id")
*/
private $userInformation;
...
}
<?php
namespace System\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class UserInformation
* @package System\Entity
* @ORM\Entity()
* @ORM\Table(name="`user_information`")
*/
class UserInformation
{
/**
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(name="id", type="bigint", options={"unsigned":true})
*/
private $id;
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment