@@ -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,17 +59,34 @@ 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 ::
66
+
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.
43
70
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::
71
+ When working with multiple connections to create your databases:
72
+
73
+ .. code-block :: bash
74
+
75
+ # Play only with "default" connection
76
+ $ php app/console doctrine:database:create
77
+
78
+ # Play only with "customer" connection
79
+ $ php app/console doctrine:database:create --connection=customer
80
+
81
+ When working with multiple entity managers to update your schema:
82
+
83
+ .. code-block :: bash
47
84
48
85
# Play only with "default" mappings
49
- php app/console doctrine:schema:update --force
86
+ $ php app/console doctrine:schema:update --force
50
87
51
88
# Play only with "customer" mappings
52
- php app/console doctrine:schema:update --force --em=customer
89
+ $ php app/console doctrine:schema:update --force --em=customer
53
90
54
91
If you *do * omit the entity manager's name when asking for it,
55
92
the default entity manager (i.e. ``default ``) is returned::
@@ -59,10 +96,10 @@ the default entity manager (i.e. ``default``) is returned::
59
96
public function indexAction()
60
97
{
61
98
// 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');
99
+ $em = $this->get('doctrine')->getManager ();
100
+ $em = $this->get('doctrine')->getManager ('default');
101
+
102
+ $customerEm = $this->get('doctrine')->getManager ('customer');
66
103
}
67
104
}
68
105
0 commit comments