Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6730445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:24:34+00:00 2026-05-26T10:24:34+00:00

I have some form, and one column have Entity type, but this entity have

  • 0

I have some form, and one column have Entity type, but this entity have another connection.

In action i can $em->getDoctrine()->getEntityManager('name')

How to change connection in form class?

Maybe can possibly change connection in entity class.
Like this

orm:
    default_entity_manager: default
    entity_managers:
        owner:
            connection: owner
            mappings:
                RealestateCoreBundle:
                    Entity: MyEntity

UPDATED:

I found answer here 🙂

http://symfony.com/doc/2.0/reference/forms/types/entity.html#em

But how i can change connection in data fixtures class?

I try:

<?php

namespace Realestate\CoreBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Realestate\CoreBundle\Entity\Owner;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class OwnerFixtures implements FixtureInterface, ContainerAwareInterface
{

    private $container;

    public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
    }

    public function load($manager)
    {
        $this->container->get('doctrine')->getEntityManager('owner');

        for ($i = 0; $i < 100; $i++) {
            $owner = new Owner();
            $owner->setName('name-' . $i);
            $owner->setTelephone(mt_rand(100000, 999999));
            $manager->persist($owner);
        }

        $manager->flush();
    }

}

but didnt work 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:24:35+00:00Added an answer on May 26, 2026 at 10:24 am

    When loading fixtures you can use the flag when executing the console command to change the entity manager:

    Executing Fixtures

    php app/console doctrine:fixtures:load --em=manager_name
    

    Alternatively you could check out this section in the same docs:

    Using the container in fixtures

    If your fixture class has access to the container then you could load any entity manager you wish.

    $container->get('doctrine')->getEntityManager('manager_name');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one form calling a method in another form. but the method in
i have one form which have some input box and some select box. i
I have a very simple XAML form, that has one namespace definition. For some
I have jsf page: .... <form jsfc=h:form action=> <h:dataTable value=#{newMusician.strings} var=preferredMusicGenre id=musicGenresSelectTable> <h:column> <h:inputText
This is my first Rails project. For some reason, I can't post to one
I'm trying to make the following form in JSF 2.0 but a have some
I have some tabular data. In the last column, I have 2 divs, one
Please help! I have some form elements in a div on a page: <div
I have some data of the form Key ID Link 1 MASTER 123 2
I have some javascript which catches changes to a form then calls the form's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.