You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 4, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 4, 2022. It is now read-only.
As a user I want to have dynamic database connection via config so that I can setup my database connections #1
Users want to setup their database connections. We need to support some kind of multiple connections that are configured by the end user.
The database connection settings in Symfony2 are setup via the config.yml file. This file contains a Doctrine/Dbal config section that we will use for connecting to the different databases. In this file it is possible to configure multiple named database connections.
A possibile option would be to dynamically push config data into this file. This file should then be writable by the web server. By getting the 'Service' from the controller by doing the following the Database connection can be acquired.
I do not know if making the generic configuration writable from within the application is security-wise a good idea. is it perhaps possible to have our own SQLite where to store settings (easy to export as well), which can be read by the application and which dynamically spawns a DBAL in the DIC?
We can get a new DBAL connection using the \Doctrine\DBAL\DriverManager::getConnection($params) method. This returns a new connection with the given $params. These params are the settings for the connection. These can be found via: http://www.doctrine-project.org/api/dbal/2.0/doctrine/dbal/drivermanager.html
What I suggest to do is to create a ConnectionFactory to manage these connections. This factory class contains the factory method that will create a connection via the DriverManager using data from our sqlite database.
The sqlite database should at least have a table that contains the database connection information. This table can and probably will contain information of multiple connections.
Activity
mvriel commentedon Oct 24, 2011
I do not know if making the generic configuration writable from within the application is security-wise a good idea. is it perhaps possible to have our own SQLite where to store settings (easy to export as well), which can be read by the application and which dynamically spawns a DBAL in the DIC?
Jerommeke4 commentedon Nov 2, 2011
We can get a new DBAL connection using the \Doctrine\DBAL\DriverManager::getConnection($params) method. This returns a new connection with the given $params. These params are the settings for the connection. These can be found via: http://www.doctrine-project.org/api/dbal/2.0/doctrine/dbal/drivermanager.html
What I suggest to do is to create a ConnectionFactory to manage these connections. This factory class contains the factory method that will create a connection via the DriverManager using data from our sqlite database.
The sqlite database should at least have a table that contains the database connection information. This table can and probably will contain information of multiple connections.