From a0c57169f4d591e07a06e8f4e05b7dfbb983ad9f Mon Sep 17 00:00:00 2001 From: dcramble Date: Thu, 4 Oct 2012 17:51:05 -0700 Subject: [PATCH 1/2] Add connection configuration details --- .../doctrine/multiple_entity_managers.rst | 50 ++++++++++++++++--- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/cookbook/doctrine/multiple_entity_managers.rst b/cookbook/doctrine/multiple_entity_managers.rst index f246ff1d505..92150f9ee5b 100644 --- a/cookbook/doctrine/multiple_entity_managers.rst +++ b/cookbook/doctrine/multiple_entity_managers.rst @@ -23,6 +23,26 @@ The following configuration code shows how you can configure two entity managers .. code-block:: yaml doctrine: + dbal: + default_connection: default + connections: + default: + driver: %database_driver% + host: %database_host% + port: %database_port% + dbname: %database_name% + user: %database_user% + password: %database_password% + charset: UTF8 + customer: + driver: %database_driver2% + host: %database_host2% + port: %database_port2% + dbname: %database_name2% + user: %database_user2% + password: %database_password2% + charset: UTF8 + orm: default_entity_manager: default entity_managers: @@ -39,11 +59,25 @@ The following configuration code shows how you can configure two entity managers In this case, you've defined two entity managers and called them ``default`` and ``customer``. The ``default`` entity manager manages entities in the ``AcmeDemoBundle`` and ``AcmeStoreBundle``, while the ``customer`` entity -manager manages entities in the ``AcmeCustomerBundle``. +manager manages entities in the ``AcmeCustomerBundle``. You've also defined +two connections, one for each entity manager. + +.. note:: -When working with multiple entity managers, you should be explicit about which -entity manager you want. If you *do* omit the entity manager's name when you -update your schema, the default (i.e. ``default``) is used:: + When working with multiple connections and entity managers, you should be + explicit about which configuration you want. If you *do* omit the name of + the connection or entity manager, the default (i.e. ``default``) is used. + + +When working with multiple connections to create your databases:: + + # Play only with "default" connection + php app/console doctrine:database:create + + # Play only with "customer" connection + php app/console doctrine:database:create --connection=customer + +When working with multiple entity managers to update your schema:: # Play only with "default" mappings php app/console doctrine:schema:update --force @@ -59,10 +93,10 @@ the default entity manager (i.e. ``default``) is returned:: public function indexAction() { // both return the "default" em - $em = $this->get('doctrine')->getEntityManager(); - $em = $this->get('doctrine')->getEntityManager('default'); - - $customerEm = $this->get('doctrine')->getEntityManager('customer'); + $em = $this->get('doctrine')->getManager(); + $em = $this->get('doctrine')->getManager('default'); + + $customerEm = $this->get('doctrine')->getManager('customer'); } } From b255dd9f82ac371c0e67d6e621aaa3523339044a Mon Sep 17 00:00:00 2001 From: dcramble Date: Fri, 5 Oct 2012 14:58:36 -0700 Subject: [PATCH 2/2] Convert shell command examples to bash-blocks --- cookbook/doctrine/multiple_entity_managers.rst | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cookbook/doctrine/multiple_entity_managers.rst b/cookbook/doctrine/multiple_entity_managers.rst index 92150f9ee5b..78c368b0a1e 100644 --- a/cookbook/doctrine/multiple_entity_managers.rst +++ b/cookbook/doctrine/multiple_entity_managers.rst @@ -68,22 +68,25 @@ two connections, one for each entity manager. explicit about which configuration you want. If you *do* omit the name of the connection or entity manager, the default (i.e. ``default``) is used. - -When working with multiple connections to create your databases:: +When working with multiple connections to create your databases: + +.. code-block:: bash # Play only with "default" connection - php app/console doctrine:database:create + $ php app/console doctrine:database:create # Play only with "customer" connection - php app/console doctrine:database:create --connection=customer + $ php app/console doctrine:database:create --connection=customer + +When working with multiple entity managers to update your schema: -When working with multiple entity managers to update your schema:: +.. code-block:: bash # Play only with "default" mappings - php app/console doctrine:schema:update --force + $ php app/console doctrine:schema:update --force # Play only with "customer" mappings - php app/console doctrine:schema:update --force --em=customer + $ php app/console doctrine:schema:update --force --em=customer If you *do* omit the entity manager's name when asking for it, the default entity manager (i.e. ``default``) is returned::