Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么Codeigniter更新(1.7.2至2.0.3)后配置项调用返回错误_Php_Codeigniter_Codeigniter 2 - Fatal编程技术网

Php 为什么Codeigniter更新(1.7.2至2.0.3)后配置项调用返回错误

Php 为什么Codeigniter更新(1.7.2至2.0.3)后配置项调用返回错误,php,codeigniter,codeigniter-2,Php,Codeigniter,Codeigniter 2,我使用CI更新文档将应用程序从1.7.2更新到2.0.3。 但是现在我被活动记录文件(application/libraries/Activerecord.php)中的一个错误所困扰 在活动记录中,我尝试使用$this->config对象获取配置项 我的代码:-$this->config->item('item_name') 但它返回了一个错误 错误:-调用null上的成员函数项() 在CI更新期间,我根据CI文档执行了以下操作 更新了CodeIgniter系统文件。, 更新了帮助程序的插件。,

我使用CI更新文档将应用程序从1.7.2更新到2.0.3。 但是现在我被活动记录文件(application/libraries/Activerecord.php)中的一个错误所困扰

在活动记录中,我尝试使用
$this->config
对象获取配置项

我的代码:-
$this->config->item('item_name')

但它返回了一个错误

错误:-调用null上的成员函数项()

在CI更新期间,我根据CI文档执行了以下操作

更新了CodeIgniter系统文件。, 更新了帮助程序的插件。, 更新了类扩展。, 已更新父构造函数调用。, 已将核心扩展移动到应用程序/核心。, 正在更新配置文件夹更改。,
索引文件已更改。,

您需要重命名此文件:

require dirname( FILE ) . '/../../../config/your_custom_config.php';
为此:

require dirname( __FILE__ ) . '/your_custom_config.php';
并确保正确设置自定义配置路径。
或者,您也可以在控制器中使用内置的配置加载程序方法:

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

在您的库Activerecord.php中

问题是。。。您不能使用codeigniter中的所有可用类。。为了进行加载配置

$this->config->item('item_name');.
换成

$this->ci =& get_instance();
$this->ci->config->item('item_name');

您以前是否在版本
1.7.2
上使用过自定义配置文件?@HastaDhana是的,我在以前的CI中使用过自定义配置文件。我在application/config/config.php中包含了定制的配置文件,比如“requiredirname(file)。”/../../../../config/config.php“;”。。