Created
February 16, 2012 16:00
-
-
Save peterjmit/1845982 to your computer and use it in GitHub Desktop.
Mapping Indexes with Yaml in Doctrine 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example. A category entity with a url friendly 'slug' | |
# we want to index on this slug because we will be using it | |
# to query with. | |
Vendor\CategoryBundle\Entity\Category: | |
type: entity | |
table: category | |
indexes: | |
# the name of the index | |
category_slug_idx: | |
# Columns is an array, specify multiple columns for | |
# a compound index | |
columns: [ slug ] | |
id: | |
id: | |
type: integer | |
generator: { strategy: AUTO } | |
fields: | |
name: | |
type: string | |
slug: | |
type: string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example 2: a blog article with multiple image entities | |
# We want to add a caption for each image so we create a Join table | |
# with meta data, and the primary key is a composite of the primary keys | |
# from both the blog and image entity | |
Vendor\BlogBundle\Entity\BlogImage: | |
type: entity | |
table: blog_image | |
# use two fields for our identifier | |
id: | |
blog: | |
# flag as an association key | |
associationKey: true | |
image: | |
associationKey: true | |
fields: | |
caption: | |
type: string | |
# Specify our relationships for above | |
manyToOne: | |
project: | |
targetEntity: Vendor\BlogBundle\Entity\Blog | |
inversedBy: images | |
oneToOne: | |
image: | |
targetEntity: Vendor\ImageBundle\Entity\Image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment