可以使用codeigniter中的特定文件设置变量host
,dbname
,username
和password
?如果可能,如何在特定文件中设置变量连接也可以在config/database.php
中读取?我们知道CI使用config/database.php
来配置连接。如何设置连接变量与CodeIgniter中的特定文件
EDITED
这是代码:
rootweb/index.php的
$this->config->load('config', TRUE);
rootweb/config.php中
$config['host']="localhost";
$config['dbname']="mydb";
$config['username']="myusername";
$config['password']="mypass";
我也尝试使用这样的:
$config['dsn']="postgre://myusername:[email protected]/mydb?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir=/path/to/cache";
的application/config/config.php文件
include ('config.php');
的application/config/database.php中
$host = $this->config->item('host', 'config');
$dbname = $this->config->item('dbname', 'config');
$username = $this->config->item('username', 'config');
$password = $this->config->item('password', 'config');
$dsn = $this->config->item('dsn', 'config');
$db['default'] = array(
'dsn' => $dsn,
'hostname' => $host,
'username' => $username,
'password' => $password,
'database' => $dbname,
'dbdriver' => 'postgre',
...
);
而且仍然呈现空白页。
发布你到目前为止所做的事 –
你在做什么?仔细阅读codeigniter手册。如何创建配置和创建配置文件的位置。 – Gaurav