首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以在应用程序文件夹中的active_group中设置index.php吗?

我可以在应用程序文件夹中的active_group中设置index.php吗?
EN

Stack Overflow用户
提问于 2013-10-28 19:36:59
回答 1查看 1.9K关注 0票数 2

我有超过一个用户使用相同的应用程序文件夹。所以他们共享database.php。

我已将所有信息添加到$db矩阵中。现在,我只需要在$active_group文件中设置index.php。

不是在控制器里,不是在模型里。

有什么办法吗?

我尝试在$active_group = 'test';的开头添加index.php,在用户配置部分尝试,在加载引导之前尝试,最后尝试。什么都没用。

我的database.php

代码语言:javascript
复制
$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“。

这不应该那么难,但我找不到办法.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-28 21:58:48

不能在$active_group中设置index.php,因为它将在加载数据库配置文件时被覆盖,但您可以这样做

define('ACTIVE_SITE', 'default_new');添加到index.php文件

然后在数据库文件中将$active_group更改为

代码语言:javascript
复制
if (defined('ACTIVE_SITE')) {
    $active_group = ACTIVE_SITE;
} else {
    $active_group = 'default';
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19643583

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档