From 3bd916f763911944e9ddea6995b391fb7e28a907 Mon Sep 17 00:00:00 2001 From: Mauro Pinto Date: Mon, 1 Sep 2014 12:48:10 +0100 Subject: [PATCH 1/2] Document embeddables column prefixing --- docs/en/tutorials/embeddables.rst | 96 +++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/docs/en/tutorials/embeddables.rst b/docs/en/tutorials/embeddables.rst index 5ec207fa6..4c95016f6 100644 --- a/docs/en/tutorials/embeddables.rst +++ b/docs/en/tutorials/embeddables.rst @@ -74,6 +74,102 @@ In terms of your database schema, Doctrine will automatically inline all columns from the ``Address`` class into the table of the ``User`` class, just as if you had declared them directly there. +Column Prefixing +---------------- + +By default, Doctrine prefixes your columns by using the value object name. + +You can change this behaviour in the following ways: + +.. configuration-block:: + + .. code-block:: php + + + + + + + + + + + + + + + + + + .. code-block:: yaml + + # Default behaviour + # Will name your columns by prefixing them with "address_" + User: + type: entity + embedded: + address: + class: Address + + # Will name your columns by prefixing them with "prefix_" + User: + type: entity + embedded: + address: + class: Address + columnPrefix: prefix_ + + # Will NOT prefix your columns + User: + type: entity + embedded: + address: + class: Address + columnPrefix: false + + +DQL +--- + You can also use mapped fields of embedded classes in DQL queries, just as if they were declared in the ``User`` class: From 857fed0310e0cb85589ab087ddab5a3cebb4fc1f Mon Sep 17 00:00:00 2001 From: Mauro Pinto Date: Wed, 3 Sep 2014 11:13:28 +0100 Subject: [PATCH 2/2] Make embeddable doc more succinct, fix xml --- docs/en/tutorials/embeddables.rst | 85 +++++++++++-------------------- 1 file changed, 30 insertions(+), 55 deletions(-) diff --git a/docs/en/tutorials/embeddables.rst b/docs/en/tutorials/embeddables.rst index 4c95016f6..cf13fd56e 100644 --- a/docs/en/tutorials/embeddables.rst +++ b/docs/en/tutorials/embeddables.rst @@ -77,9 +77,16 @@ just as if you had declared them directly there. Column Prefixing ---------------- -By default, Doctrine prefixes your columns by using the value object name. +By default, Doctrine names your columns by prefixing them, using the value +object name. -You can change this behaviour in the following ways: +Following the example above, your columns would be named as ``address_street``, +``address_postalCode``... + +You can change this behaviour to meet your needs by changing the +``columnPrefix`` attribute in the ``@Embeddable`` notation. + +The following example shows you how to set your prefix to ``myPrefix_``: .. configuration-block:: @@ -87,33 +94,36 @@ You can change this behaviour in the following ways: + + - /** @Entity */ - class User - { - /** @Embedded(class = "Address", columnPrefix = "prefix_") */ - private $address; - } + .. code-block:: yaml - // Will NOT prefix your columns - // Your columns will be named as: - // "street", "postalCode" ... + User: + type: entity + embedded: + address: + class: Address + columnPrefix: myPrefix_ + +To have Doctrine drop the prefix and use the value object's property name +directly, set ``columnPrefix=false`` (not yet supported with XML configuration): + +.. configuration-block:: + + .. code-block:: php + + - - - - - - - - - - - - - - - .. code-block:: yaml - # Default behaviour - # Will name your columns by prefixing them with "address_" - User: - type: entity - embedded: - address: - class: Address - - # Will name your columns by prefixing them with "prefix_" - User: - type: entity - embedded: - address: - class: Address - columnPrefix: prefix_ - - # Will NOT prefix your columns User: type: entity embedded: