magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

table_prefix is used globally for all db connections #151

Open OvalMedia opened 5 years ago

OvalMedia commented 5 years ago

When using an additional custom database connection you get in trouble when one of your databases uses table prefixes and the other does not.

env.php:

'db' => [
    'table_prefix' => 'abc_',
    'connection' => [
        'default' => [
            'host' => 'localhost',
            'dbname' => 'db1',
            'username' => 'db1',
            'password' => 'pw1',
            'active' => '1'
        ],
        'custom' => [
            'host' => 'localhost',
            'dbname' => 'db2',
            'username' => 'db2',
            'password' => 'pw2',
            'active' => '1'
        ]
    ]
],

I have a case where the magento DB uses prefixes and the custom database does not. With this setup the table_prefix is applied to all connections.

It would make so much more sense if table_prefix could be applied for each connection separately:

'db' => [
    'connection' => [
        'default' => [
            'host' => 'localhost',
            'dbname' => 'db1',
            'username' => 'db1',
            'password' => 'pw1',
            'active' => '1',
                        'table_prefix' => 'abc_',
        ],
        'custom' => [
            'host' => 'localhost',
            'dbname' => 'db2',
            'username' => 'db2',
            'password' => 'pw2',
            'active' => '1',
                        'table_prefix' => '',
        ]
    ]
],