@@ -23,6 +23,26 @@ The following configuration code shows how you can configure two entity managers
23
23
.. code-block :: yaml
24
24
25
25
doctrine :
26
+ dbal :
27
+ default_connection : default
28
+ connections :
29
+ default :
30
+ driver : %database_driver%
31
+ host : %database_host%
32
+ port : %database_port%
33
+ dbname : %database_name%
34
+ user : %database_user%
35
+ password : %database_password%
36
+ charset : UTF8
37
+ customer :
38
+ driver : %database_driver2%
39
+ host : %database_host2%
40
+ port : %database_port2%
41
+ dbname : %database_name2%
42
+ user : %database_user2%
43
+ password : %database_password2%
44
+ charset : UTF8
45
+
26
46
orm :
27
47
default_entity_manager : default
28
48
entity_managers :
@@ -39,11 +59,25 @@ The following configuration code shows how you can configure two entity managers
39
59
In this case, you've defined two entity managers and called them ``default ``
40
60
and ``customer ``. The ``default `` entity manager manages entities in the
41
61
``AcmeDemoBundle `` and ``AcmeStoreBundle ``, while the ``customer `` entity
42
- manager manages entities in the ``AcmeCustomerBundle ``.
62
+ manager manages entities in the ``AcmeCustomerBundle ``. You've also defined
63
+ two connections, one for each entity manager.
64
+
65
+ .. note ::
43
66
44
- When working with multiple entity managers, you should be explicit about which
45
- entity manager you want. If you *do * omit the entity manager's name when you
46
- update your schema, the default (i.e. ``default ``) is used::
67
+ When working with multiple connections and entity managers, you should be
68
+ explicit about which configuration you want. If you *do * omit the name of
69
+ the connection or entity manager, the default (i.e. ``default ``) is used.
70
+
71
+
72
+ When working with multiple connections to create your databases::
73
+
74
+ # Play only with "default" connection
75
+ php app/console doctrine:database:create
76
+
77
+ # Play only with "customer" connection
78
+ php app/console doctrine:database:create --connection=customer
79
+
80
+ When working with multiple entity managers to update your schema::
47
81
48
82
# Play only with "default" mappings
49
83
php app/console doctrine:schema:update --force
@@ -59,10 +93,10 @@ the default entity manager (i.e. ``default``) is returned::
59
93
public function indexAction()
60
94
{
61
95
// both return the "default" em
62
- $em = $this->get('doctrine')->getEntityManager ();
63
- $em = $this->get('doctrine')->getEntityManager ('default');
64
-
65
- $customerEm = $this->get('doctrine')->getEntityManager ('customer');
96
+ $em = $this->get('doctrine')->getManager ();
97
+ $em = $this->get('doctrine')->getManager ('default');
98
+
99
+ $customerEm = $this->get('doctrine')->getManager ('customer');
66
100
}
67
101
}
68
102
0 commit comments