Codeigniter Datamapper ORM php 7 静态问题

标签 codeigniter orm datamapper

当我将我的服务器升级到 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->configself::get_config_object()
现在应该可以正常运行了。

关于Codeigniter Datamapper ORM php 7 静态问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44490616/

相关文章:

php - 尝试在数据库中使用 ckeip 和 codeigniter 更新数据

php - 为什么 mysqli::multi_query 在一定数量的行后停止?

python - SqlAlchemy 没有定义这样的多态身份

ruby - datamapper 多对多表名

oop - Finder 方法应该是数据映射器的一部分,还是域类的一部分?

php - MySQL 在 php 中插入图像后函数返回 0

sql - 在 codeigniter 中不显示任何查询

java - JPA 与旧版 native SQL 共存

java - 如何使用JPA验证数据库中是否存在具有某些字段值的记录?

python - Flask SQLAlchemy 数据映射器与事件记录模式