Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Example of a OneToOne, bidirectional, PK as FK association.
<?php
class Book
{
/**
* @ORM\Id
* @ORM\Column()
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @ORM\OneToOne(targetEntity="HardCover", mappedBy="book", cascade={"persist"})
*/
protected $hardCover;
public function getHardCover()
{
return $this->hardCover;
}
}
class HardCover
{
/**
* @ORM\Id
* @ORM\OneToOne(targetEntity="Book", inversedBy="hardCover")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_book", referencedColumnName="id")
* })
*/
protected $book;
public function getBook()
{
return $this->book;
}
public function setBook(Book $book)
{
$this->book = $book;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.