当我将我的服务器升级到 php7 codeigniter 时,特别是 datamapper ORM 给了我这个错误......
Message: Accessing static property DataMapper::$config as non static
Filename: libraries/datamapper.php Line Number: 6474
有问题的功能是......
protected function _dmz_assign_libraries()
{
static $CI;
if ($CI || $CI =& get_instance())
{
// make sure these exists to not trip __get()
$this->load = NULL;
$this->config = NULL;
$this->lang = NULL;
// access to the loader
$this->load =& $CI->load;
// to the config
$this->config =& $CI->config;
// and the language class
$this->lang =& $CI->lang;
}
}
最佳答案
我也有同样的问题。要修复它,请尝试添加新的 protected 静态方法
protected static function get_config_object() {
$CI =& get_instance();
return $CI->config;
}
然后删除或注释 6474 和 6481 行(在
_dmz_assign_libraries
中,其中值被分配给 $this->config
),最后替换所有调用
$this->config
与 self::get_config_object()
现在应该可以正常运行了。
关于Codeigniter Datamapper ORM php 7 静态问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44490616/