02-19-2019, 09:49 AM
Hello, how do I make the following change in codeigniter, it's possible?
when logging into the system check the registered email database, and log in to the related database, for example:
User: teste@teste.com
Database: xyz
User: teste2@teste.com
database: abc
after login, this will be the user session database.
I tried in many bad ways it does not work
my function of verification email x database
my database.php
trying to set the database when signing in
when logging into the system check the registered email database, and log in to the related database, for example:
User: teste@teste.com
Database: xyz
User: teste2@teste.com
database: abc
after login, this will be the user session database.
I tried in many bad ways it does not work
my function of verification email x database
Code:
function get_base_email($email)
{
$CI = & get_instance();
$CI->db->where('email', $email);
return $CI->db->get('tblusuariobanco')->row()->banco;
}
my database.php
Code:
$db['xyz'] = [
'dsn' => '', // Not Supported
'hostname' => APP_DB_HOSTNAME,
'username' => APP_DB_USERNAME,
'password' => APP_DB_PASSWORD,
'database' => 'gestor',
'dbdriver' => defined('APP_DB_DRIVER') ? APP_DB_DRIVER : 'mysqli',
'dbprefix' => '', // Not Supported
'pconnect' => false,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => false,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => $db_encrypt,
'compress' => false,
'stricton' => false,
'failover' => [],
'save_queries' => true,
];
$db['abc'] = [
'dsn' => '', // Not Supported
'hostname' => APP_DB_HOSTNAME,
'username' => APP_DB_USERNAME,
'password' => APP_DB_PASSWORD,
'database' => 'xxx',
'dbdriver' => defined('APP_DB_DRIVER') ? APP_DB_DRIVER : 'mysqli',
'dbprefix' => '', // Not Supported
'pconnect' => false,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => false,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => $db_encrypt,
'compress' => false,
'stricton' => false,
'failover' => [],
'save_queries' => true,
];
trying to set the database when signing in
Code:
$active_group = get_base_email($email);