5

When I upgraded my server to php7 codeigniter and in particular datamapper ORM gives me this error...

Message: Accessing static property DataMapper::$config as non static
Filename: libraries/datamapper.php Line Number: 6474

the function in question is...

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;
    }
}
David Newcomb
  • 10,639
  • 3
  • 49
  • 62
galipmedia
  • 77
  • 5

3 Answers3

8

I have the same problem. To fix it, try to add new protected static method

protected static function get_config_object() {
    $CI =& get_instance();

    return $CI->config;
}

then delete or comment the lines 6474 and 6481 (in _dmz_assign_libraries, where values are assigned to $this->config),

and finally replace all calls $this->config with self::get_config_object()

It should run correctly now.

SandPiper
  • 2,816
  • 5
  • 30
  • 52
3

Try to suppress error with @, eg:

@$this->config =& $CI->config;
TomoMiha
  • 1,218
  • 1
  • 14
  • 12
0

I faced the same problem.

FIX: Replace the actual datamapper.php library version with the latest one.

As mentioned in the official library website

Latest library version (1.8.3-dev) - source: https://github.com/saekort/datamapper/blob/master/application/libraries/datamapper.php

Qu4k3
  • 185
  • 3
  • 16