我有超过一个用户使用相同的应用程序文件夹。所以他们共享database.php。
我已将所有信息添加到$db矩阵中。现在,我只需要在$active_group文件中设置index.php。
不是在控制器里,不是在模型里。
有什么办法吗?
我尝试在$active_group = 'test';的开头添加index.php,在用户配置部分尝试,在加载引导之前尝试,最后尝试。什么都没用。
我的database.php
$active_group = "";
$active_record = TRUE;
// Ale
$db['ale']['hostname'] = 'localhost';
$db['ale']['username'] = 'root';
$db['ale']['password'] = '';
$db['ale']['database'] = 'eo_ale';
$db['ale']['dbdriver'] = 'mysql';
$db['ale']['dbprefix'] = 'ed_';
$db['ale']['pconnect'] = TRUE;
$db['ale']['db_debug'] = TRUE;
$db['ale']['cache_on'] = FALSE;
$db['ale']['cachedir'] = '';
$db['ale']['char_set'] = 'utf8';
$db['ale']['dbcollat'] = 'utf8_general_ci';
$db['ale']['swap_pre'] = '';
$db['ale']['autoinit'] = TRUE;
$db['ale']['stricton'] = FALSE;
// Sre
$db['sre']['hostname'] = 'localhost';
$db['sre']['username'] = 'root';
$db['sre']['password'] = '';
$db['sre']['database'] = 'eo_sre';
$db['sre']['dbdriver'] = 'mysql';
$db['sre']['dbprefix'] = 'ed_';
$db['sre']['pconnect'] = TRUE;
$db['sre']['db_debug'] = TRUE;
$db['sre']['cache_on'] = FALSE;
$db['sre']['cachedir'] = '';
$db['sre']['char_set'] = 'utf8';
$db['sre']['dbcollat'] = 'utf8_general_ci';
$db['sre']['swap_pre'] = '';
$db['sre']['autoinit'] = TRUE;
$db['sre']['stricton'] = FALSE;因此,我现在想要的是创建一个函数,在ale登录时,设置$active_group="ale",或者当sre登录时,设置$active_group = "sre“。
这不应该那么难,但我找不到办法.
发布于 2013-10-28 21:58:48
不能在$active_group中设置index.php,因为它将在加载数据库配置文件时被覆盖,但您可以这样做
将define('ACTIVE_SITE', 'default_new');添加到index.php文件
然后在数据库文件中将$active_group更改为
if (defined('ACTIVE_SITE')) {
$active_group = ACTIVE_SITE;
} else {
$active_group = 'default';
}https://stackoverflow.com/questions/19643583
复制相似问题