【问题标题】:Codeigniter Datamapper ORM php 7 static issueCodeigniter Datamapper ORM php 7静态问题
【发布时间】:2017-11-13 09:49:09
【问题描述】:

当我将服务器升级到 php7 codeigniter 时,特别是 datamapper ORM 给了我这个错误...

消息:以非静态方式访问静态属性 DataMapper::$config
文件名:libraries/datamapper.php 行号: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;
    }
}

【问题讨论】:

    标签: codeigniter orm datamapper


    【解决方案1】:

    我遇到了同样的问题。

    修复:将实际的datamapper.php库版本替换为最新版本。

    official library website中所述

    最新的库版本 (1.8.3-dev) - 来源:https://github.com/saekort/datamapper/blob/master/application/libraries/datamapper.php

    【讨论】:

      【解决方案2】:

      尝试用@抑制错误,例如:

      @$this->config =& $CI->config;
      

      【讨论】:

        【解决方案3】:

        我也有同样的问题。要修复它,请尝试添加新的受保护静态方法

        protected static function get_config_object() {
            $CI =& get_instance();
        
            return $CI->config;
        }
        

        然后删除或注释第 6474 和 6481 行(在 _dmz_assign_libraries 中,其中值分配给 $this->config),

        最后用self::get_config_object()替换所有调用$this->config

        它现在应该可以正常运行了。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-12-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多