Skip to content
This repository was archived by the owner on Dec 4, 2022. It is now read-only.
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

Open

Description

@Jerommeke4

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.

$connection = $this->get('doctrine.dbal.<name>_connection);

Need to investigate some more on this issue

Activity

  1. mvriel commented on Oct 24, 2011

    @mvriel
    Owner

    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?

  2. Jerommeke4 commented on Nov 2, 2011

    @Jerommeke4
    CollaboratorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions