Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 3 multiple dynamic connexion database mysql
#1


I have several clients that have the same database architecture (mysql) and the same solution (no specific development) problem that now I do directories for each client and in each config.php file I connect to Database as follows:
For client x:

Code:
$db['default'] = array(
   'dsn' => '',
   'hostname' => 'localhost',
   'username' => '***',
   'password' => '***',
   'database' => 'comuniksales_x',
   'dbdriver' => 'mysqli',
   'dbprefix' => '',
   'pconnect' => FALSE,
   'db_debug' => (ENVIRONMENT !== 'production'),
   'cache_on' => FALSE,
   'cachedir' => '',
   'char_set' => 'utf8',
   'dbcollat' => 'utf8_general_ci',
   'swap_pre' => '',
   'encrypt' => FALSE,
   'compress' => FALSE,
   'stricton' => FALSE,
   'failover' => array(),
   'save_queries' => TRUE
);

and for client y :

Code:
$db['default'] = array(
       'dsn' => '',
       'hostname' => 'localhost',
       'username' => '***',
       'password' => '***',
       'database' => 'comuniksales_y',
       'dbdriver' => 'mysqli',
       'dbprefix' => '',
       'pconnect' => FALSE,
       'db_debug' => (ENVIRONMENT !== 'production'),
       'cache_on' => FALSE,
       'cachedir' => '',
       'char_set' => 'utf8',
       'dbcollat' => 'utf8_general_ci',
       'swap_pre' => '',
       'encrypt' => FALSE,
       'compress' => FALSE,
       'stricton' => FALSE,
       'failover' => array(),
       'save_queries' => TRUE
   );

As you see I change only the name of the database
N.B: that in each database there are the identifiers of the clients
I have added a new text field in the authentication page for the client to enter the account (ex: client x -> x, client y -> y, ...) so that I can retrieve x and To put in the config but i arrive not field in the authentification
Reply




Theme © iAndrew 2016 - Forum software by © MyBB