Skip to content

Commit 1e3d3cd

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents f099591 + 9e77bfb commit 1e3d3cd

File tree

2 files changed

+76
-6
lines changed

2 files changed

+76
-6
lines changed

cookbook/doctrine/dbal.rst

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ with the most popular relational databases. In other words, the DBAL library
1717
makes it easy to execute queries and perform other database actions.
1818

1919
.. tip::
20-
20+
2121
Read the official Doctrine `DBAL Documentation`_ to learn all the details
2222
and capabilities of Doctrine's DBAL library.
2323

@@ -37,7 +37,7 @@ To get started, configure the database connection parameters:
3737
charset: UTF8
3838
3939
.. code-block:: xml
40-
40+
4141
// app/config/config.xml
4242
<doctrine:config>
4343
<doctrine:dbal
@@ -97,6 +97,63 @@ mapping types, read Doctrine's `Custom Mapping Types`_ section of their document
9797
custom_first: Acme\HelloBundle\Type\CustomFirst
9898
custom_second: Acme\HelloBundle\Type\CustomSecond
9999
100+
.. code-block:: xml
101+
102+
<!-- app/config/config.xml -->
103+
<container xmlns="http://symfony.com/schema/dic/services"
104+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
105+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
106+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
107+
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
108+
109+
<doctrine:config>
110+
<doctrine:dbal>
111+
<doctrine:dbal default-connection="default">
112+
<doctrine:connection>
113+
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
114+
</doctrine:connection>
115+
</doctrine:dbal>
116+
</doctrine:config>
117+
</container>
118+
119+
.. code-block:: php
120+
121+
// app/config/config.php
122+
$container->loadFromExtension('doctrine', array(
123+
'dbal' => array(
124+
'connections' => array(
125+
'default' => array(
126+
'mapping_types' => array(
127+
'enum' => 'string',
128+
),
129+
),
130+
),
131+
),
132+
));
133+
134+
Registering Custom Mapping Types in the SchemaTool
135+
--------------------------------------------------
136+
137+
The SchemaTool is used to inspect the database to compare the schema. To
138+
achieve this task, it needs to know which mapping type needs to be used
139+
for each database types. Registering new ones can be done through the configuration.
140+
141+
Let's map the ENUM type (not suppoorted by DBAL by default) to a the ``string``
142+
mapping type:
143+
144+
.. configuration-block::
145+
146+
.. code-block:: yaml
147+
148+
# app/config/config.yml
149+
doctrine:
150+
dbal:
151+
connection:
152+
default:
153+
// Other connections parameters
154+
mapping_types:
155+
enum: string
156+
100157
.. code-block:: xml
101158
102159
<!-- app/config/config.xml -->
@@ -115,7 +172,7 @@ mapping types, read Doctrine's `Custom Mapping Types`_ section of their document
115172
</container>
116173
117174
.. code-block:: php
118-
175+
119176
// app/config/config.php
120177
$container->loadFromExtension('doctrine', array(
121178
'dbal' => array(

reference/configuration/doctrine.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Configuration Reference
3030
charset: UTF8
3131
logging: %kernel.debug%
3232
platform_service: MyOwnDatabasePlatformService
33+
mapping_types:
34+
enum: string
3335
conn1:
3436
# ...
3537
types:
@@ -91,9 +93,12 @@ Configuration Reference
9193
charset="UTF8"
9294
logging="%kernel.debug%"
9395
platform-service="MyOwnDatabasePlatformService"
94-
/>
96+
>
97+
<doctrine:option key="foo">bar</doctrine:option>
98+
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
99+
</doctrine:connection>
95100
<doctrine:connection name="conn1" />
96-
<doctrine:type name="custom" class="Acme\HelloBundle\MyCustomType" />
101+
<doctrine:type name="custom">Acme\HelloBundle\MyCustomType</doctrine:type>
97102
</doctrine:dbal>
98103
99104
<doctrine:orm default-entity-manager="default" auto-generate-proxy-classes="true" proxy-namespace="Proxies" proxy-dir="%kernel.cache_dir%/doctrine/orm/Proxies">
@@ -235,6 +240,10 @@ can configure. The following block shows all possible configuration keys:
235240
charset: UTF8
236241
logging: %kernel.debug%
237242
platform_service: MyOwnDatabasePlatformService
243+
mapping_types:
244+
enum: string
245+
types:
246+
custom: Acme\HelloBundle\MyCustomType
238247
239248
.. code-block:: xml
240249
@@ -258,7 +267,11 @@ can configure. The following block shows all possible configuration keys:
258267
charset="UTF8"
259268
logging="%kernel.debug%"
260269
platform-service="MyOwnDatabasePlatformService"
261-
/>
270+
>
271+
<doctrine:option key="foo">bar</doctrine:option>
272+
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
273+
<doctrine:type name="custom">Acme\HelloBundle\MyCustomType</doctrine:type>
274+
</doctrine:dbal>
262275
</doctrine:config>
263276
264277
If you want to configure multiple connections in YAML, put them under the

0 commit comments

Comments
 (0)