There are 2 databases used in Symfony2 project. I need to change second database details on the fly.
Is there any way to use container setParameter() in a function in controller of Symfony2?
Below is a piece of code where I need to change database name on the fly :
$container = $this->container;
$container->setParameter('second_database_host','localhost');
$container->setParameter('second_database_name','test');
$container->setParameter('second_database_user','root');
$container->setParameter('second_database_password','root');
$parameter_bag = $container->getParameterBag();
$service_manager = $container->get('projects_objects.manager');
$object_import = $service_manager->import($service_type));
But above code gives error as Impossible to call set() on a frozen ParameterBag.
Is there any other way from where I can change these parameters?