Answer the question
In order to leave comments, you need to log in
Where to store user settings?
Where to store user settings like title, database settings. What would users be able to edit them through the form on the site?
Answer the question
In order to leave comments, you need to log in
Let me ask you, why would you allow users to edit database connection settings?
class YourService extends ContainerAware
{
public function switchDatabase($dbName, $dbUser, $dbPass)
{
$connection = $this->container->get(sprintf('doctrine.dbal.%s_connection', 'dynamic_conn'));
$connection->close(); // for sure ;)
$refConn = new \ReflectionObject($connection);
$refParams = $refConn->getProperty('_params');
$refParams->setAccessible('public'); //we have to change it for a moment
$params = $refParams->getValue($connection);
$params['dbname'] = $dbName;
$params['user'] = $dbUser;
$params['password'] = $dbPass;
$refParams->setAccessible('private');
$refParams->setValue($connection, $params);
$this->container->get('doctrine')->resetEntityMamager('dynamic_manager'); // for sure (unless you like broken transactions)
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question