Welcome Guest, Not a member yet? Register   Sign In
Multiple Databases
#1

Hi,
I've created my application with CI4 and have got to the point where I need to extend my database for multiple clients. My database has 20 tables (10 less than 100 rows, 10 with 100,000's rows). I intend to create a separate schema for each client and there coud be well over 1000 clients. Is it possible to manage so many different connections from the default group, and pull the relevant parameters from a pre-populated session. i.e.:
PHP Code:
$default = [
    'DSN'      => '',
    'hostname' => 'localhost',
    'username' => session()->get('db_username'),
    'password' => session()->get('db_password'),
    'database' => session()->get('db_database'),
    'DBDriver' => 'MySQLi',
    'DBPrefix' => '',
    'pConnect' => false,
    'DBDebug'  => (ENVIRONMENT !== 'production'),
    'charset'  => 'utf8',
    'DBCollat' => 'utf8_general_ci',
    'swapPre'  => '',
    'encrypt'  => false,
    'compress' => false,
    'strictOn' => false,
    'failover' => [],
    'port'    => 3306,
]; 

I suppose I have 2 questions really, 1) Is this possible?, 2) If it is possible, is it safe to do this?
I would rather not create a group per client, or have to provide every key/data pair (Custom) for every database query.
Many thanks.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB