Welcome Guest, Not a member yet? Register   Sign In
Select Database on demand
#1

[eluser]Unknown[/eluser]
Hello All,

Is there a way to allow user to select a database on demand when logging into my application?

some thing like,

Username(db username) :
Password(db password) :
Database :
[ LOGIN ]

Note: Hostname remains the same,

thoughts??

Thanks
Dev
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums!

Sure. You can just pass an array into $this->load->database();

Code:
$config['hostname'] = 'localhost';
$config['username'] = $username;
$config['password'] = $password;
$config['database'] = $database;
$config['dbdriver'] = 'mysql';
$config['dbprefix'] = '';
$config['pconnect'] = TRUE;
$config['db_debug'] = FALSE;
$config['cache_on'] = FALSE;
$config['cachedir'] = '';
$config['char_set'] = 'utf8';
$config['dbcollat'] = 'utf8_general_ci';
$config['swap_pre'] = '';
$config['autoinit'] = TRUE;
$config['stricton'] = FALSE;

$this->load->database($config);

It's all in the manual... http://ellislab.com/codeigniter/user-gui...cting.html




Theme © iAndrew 2016 - Forum software by © MyBB