简体   繁体   中英

Codeigniter PHP: Error when load config database in controller?

I have got error "Your application/config/database.php file does not appear to contain a valid configuration array." when load config database in codeigniter:

Here my controller:

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

Here my file database.php:

$active_group = 'default';
$active_record = TRUE;
$tnsname = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
        (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))';
$db['default']['hostname'] = $tnsname;
$db['default']['username'] = 'system';
$db['default']['password'] = 'xxxxxx';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'oci8';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

I load config file database and I want to change config database from controller? will know how to do that?

请在database.php中指定数据库名称(对于$db['default']['database'] ),并在控制器中提及您在设置的$this->config->load('database_name')配置文件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM