Skip to content

Update PdoServiceProvider.php#1

Open
VladimirMerk wants to merge 6 commits intoliquidbox:masterfrom
VladimirMerk:master
Open

Update PdoServiceProvider.php#1
VladimirMerk wants to merge 6 commits intoliquidbox:masterfrom
VladimirMerk:master

Conversation

@VladimirMerk
Copy link

Fixes a bug

With multiple connections with different drivers for each instance, a connection is created with arguments from the last element of the array.

Example:
$app->register(
new LiquidBox\Silex\Provider\PdoServiceProvider(null, 'pdo.dbs'),
array(
'pdo.dsn' => array(
'mysql_main' => array(
'connection' => array(
'host' => 'mysql_host',
'dbname' => 'msqlexample',
),
'username' => 'user',
'password' => 'pass',
),
'postgres_main' => array(
'driver' => 'pdo_pgsql',
'connection' => array(
'host' => 'postgres_host',
'dbname' => 'psgexample'
),
'username' => 'user',
'password' => 'password',
)
)
)
);

Result:
instances[mysql_main] = pgsql:host=postgres_host;dbname=psgexample
instances[postgres_main] = pgsql:host=postgres_host;dbname=psgexample

Fixes a bug

With multiple connections with different drivers for each instance, a connection is created with arguments from the last element of the array.

Example:
$app->register(
    new LiquidBox\Silex\Provider\PdoServiceProvider(null, 'pdo.dbs'),
    array(
        'pdo.dsn' => array(
            'mysql_main' => array(
                'connection' => array(
                    'host'    => 'mysql_host',
                    'dbname'  => 'msqlexample',
                ),
                'username' => 'user',
                'password' => 'pass',
            ),
            'postgres_main' => array(
                'driver'     => 'pdo_pgsql',
                'connection' => array(
                    'host'    => 'postgres_host',
                    'dbname'  => 'psgexample'
                ),
                'username' => 'user',
                'password' => 'password',
            )
        )
    )
);

Result:
instances[mysql_main] = pgsql:host=postgres_host;dbname=psgexample
instances[postgres_main] = pgsql:host=postgres_host;dbname=psgexample
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant