Skip to content

Instantly share code, notes, and snippets.

@JiNexus
Last active April 8, 2019 01:38
Show Gist options
  • Save JiNexus/8305b52027e622e51c56f3dc9a90c97f to your computer and use it in GitHub Desktop.
Save JiNexus/8305b52027e622e51c56f3dc9a90c97f to your computer and use it in GitHub Desktop.
Doctrine Unidirectional Association Sample 1
<?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;
...
}
<?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\OneToOne(targetEntity="System\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $user;
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment