1
0
mirror of synced 2025-01-19 15:01:40 +03:00

Document embeddables column prefixing

This commit is contained in:
Mauro Pinto 2014-09-01 12:48:10 +01:00
parent d9b43dc649
commit 3bd916f763

View File

@ -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
<?php
// Default behaviour
// Will name your columns by prefixing them with "address_"
// Your columns will be named as:
// "address_street", "address_postalCode" ...
/** @Entity */
class User
{
/** @Embedded(class = "Address") */
private $address;
}
// Will name your columns by prefixing them with "prefix_"
// Your columns will be named as:
// "prefix_street", "prefix_postalCode" ...
/** @Entity */
class User
{
/** @Embedded(class = "Address", columnPrefix = "prefix_") */
private $address;
}
// Will NOT prefix your columns
// Your columns will be named as:
// "street", "postalCode" ...
/** @Entity */
class User
{
/** @Embedded(class = "Address", columnPrefix = false) */
private $address;
}
.. code-block:: xml
<!-- Default behaviour -->
<!-- Will name your columns by prefixing them with "address_" -->
<entity name="User">
<embedded name="address" class="Address" />
</entity>
<!-- Will name your columns by prefixing them with "prefix_" -->
<entity name="User">
<embedded name="address" class="Address" columnPrefix="prefix_" />
</entity>
<!-- Will NOT prefix your columns -->
<entity name="User">
<embedded name="address" class="Address" columnPrefix="false" />
</entity>
.. 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: