Skip to content

Instantly share code, notes, and snippets.

@thesowah
Created December 10, 2013 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thesowah/7891298 to your computer and use it in GitHub Desktop.
Save thesowah/7891298 to your computer and use it in GitHub Desktop.
One-to-one && One-to-many Object relationships (YAML configuration to auto-entity generation in Symfony2)
# one-to-one, bidirectional
Customer:
oneToOne:
cart:
targetEntity: Cart
mappedBy: customer
Cart:
oneToOne:
customer:
targetEntity: Customer
inversedBy: cart
joinColumn:
name: customer_id
referencedColumnName: id
# one-to-many, bidirectional
Product:
type: entity
oneToMany:
features:
targetEntity: Feature
mappedBy: product
Feature:
type: entity
manyToOne:
product:
targetEntity: Product
inversedBy: features
joinColumn:
name: product_id
referencedColumnName: id
# Reference: http://docs.doctrine-project.org/en/latest/reference/association-mapping.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment