<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$active_group = 'default';
$query_builder = TRUE;

$db_debug = env('DB_DEBUG', ENVIRONMENT !== 'production');
if (is_string($db_debug)) {
	$db_debug = !in_array(strtolower($db_debug), array('false', '0', 'no', ''), true);
}

$db['default'] = array(
	'dsn'	=> '',
	'hostname' => env('DB_HOSTNAME', 'localhost'),
	'username' => env('DB_USERNAME', ''),
	'password' => env('DB_PASSWORD', ''),
	'database' => env('DB_DATABASE', ''),
	'dbdriver' => 'mysqli',
	'dbprefix' => '',
	'pconnect' => FALSE,
	'db_debug' => (bool) $db_debug,
	'cache_on' => FALSE,
	'cachedir' => '',
	'char_set' => 'utf8',
	'dbcollat' => 'utf8_general_ci',
	'swap_pre' => '',
	'encrypt' => FALSE,
	'compress' => FALSE,
	'stricton' => FALSE,
	'failover' => array(),
	'save_queries' => TRUE
);

$CI =& get_instance();
$usertype= $CI->session->userdata('usertype');
$host= $CI->session->userdata('host');
$dbusername= $CI->session->userdata('dbusername');
$dbname= $CI->session->userdata('dbname');
$dbpwd= $CI->session->userdata('dbpwd');
if($usertype=='Library User' || $usertype=='University'){
$db['univerdb'] = array(
 'dsn' => '',
 'hostname' => $host,
 'username' => $dbusername,
 'password' => $dbpwd,
 'database' => $dbname,
 '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
);
}

/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| Values are loaded from the project-root .env file:
|   DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_DEBUG
|
*/
