• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
system check the registered email database, and log in to the related DB

#1
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



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);
Reply

#2
@samuca.ti,

Are you sure that both database signons are working? Did you confirm it?
Reply

#3
Yes, they are, and my function returns the database correctly.
Just do not know how to do the reload of the database, for the selected.
Reply

#4
@samuca.ti,

Maybe this documentation will help you https://www.codeigniter.com/userguide3/d...-databases .
Reply

#5
already tried,
can not update the $ db variable?

I'm learning codeigniter, sorry.

after login:
I'm trying

class Authentication extends CRM_Controller
{
...
...

runkit_constant_redefine ('APP_DB', get_base_email($email));

$this->db->close();
$this->db->db_select(APP_DB);
$this->db->reconnect();
Reply

#6
@samuca.ti,

What do you mean by can not update the $db variable?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.