gpt4 book ai didi

Codeigniter HMVC + ion_auth 无法加载配置项

转载 作者:行者123 更新时间:2023-12-04 04:37:40 25 4
gpt4 key购买 nike

我已经敲了 5 个小时的头,终于解决了问题,但我就是在不知道原因的情况下无法休眠。让我先解释一下这个问题。

我使用了 codeigniter HMVC 扩展并将 ion_auth 作为单独的模块安装。

|-modules
|--auth
|---config
|-----ion_auth.php
|---controllers
|-----auth.php
|---models
|-----ion_auth_model.php
|---views

当我试图获取用户组时,我开始遇到连线 SQL 错误。然后我缩小了问题范围,发现 config/ion_auth.php 中的项目未加载到 ion_auth_model.php文件。

ERROR - 2016-02-24 20:09:26 --> Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as id, .name, .description JOIN ON .=.id WHERE . = '2'' at line 1 - Invalid query: SELECT . as id, .name, .description JOIN ON .=.id WHERE . = '2'



然后我尝试了一些东西,当我删除索引 'ion_auth'ion_auth_model.php 中的几个方法调用一切都开始起作用了。

我变了
$this->tables  = $this->config->item('tables', 'ion_auth');
$this->join = $this->config->item('join', 'ion_auth);


$this->tables  = $this->config->item('tables');
$this->join = $this->config->item('join');

谁能告诉我它为什么起作用?

最佳答案

这是文件 system\core\Config.php 中 CodeIgniter 函数 config->item() 的内部实现

/**
* Fetch a config file item
*
* @param string $item Config item name
* @param string $index Index name
* @return string|null The configuration item or NULL if the item doesn't exist
*/
public function item($item, $index = '')
{
if ($index == '')
{
return isset($this->config[$item]) ? $this->config[$item] : NULL;
}

return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : NULL;
}

当您通过 $index参数,该函数检查两个参数是否在配置中初始化并返回 config[$index] CI实例的;或 null如果其中任何一个未初始化。

如果 config[$item]未在 CI 实例中设置,该函数始终返回 null .假设情况并非如此,因为避免 $index 时您的通话不会崩溃。 .

所以当你通过 $index作为第二个参数,您的代码会因为函数返回 null 而崩溃,这意味着 config[$index]未设置 CI 实例。现在的问题是为什么它没有设置,我在这里帮不了你,但看起来你缺少加载一些模块。

最好的祝福

关于Codeigniter HMVC + ion_auth 无法加载配置项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35608344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com