Codeigniter Datamapper ORM PHP 7 static issue
When I upgraded my server to php7 codeigniter and specifically the datamapper ORM gives me this error ...
Message: Access static property DataMapper :: $ config as non-static
Filename: library / datamapper.php Line Number: 6474
function in question ...
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;
}
}
+5
source to share
2 answers
I have the same problem. To fix this, try adding a new protected static method
protected static function get_config_object() {
$CI =& get_instance();
return $CI->config;
}
then remove or comment out lines 6474 and 6481 (in _dmz_assign_libraries
where the values ββare assigned $this->config
),
and finally replace all calls $this->config
withself::get_config_object()
It should now work correctly.
+5
source to share