Welcome Guest, Not a member yet? Register   Sign In
Сannot use the same name controllers and library?
#1

controller Design.php
Code:
class Design extends CI_Controller {
    function __construct() {}
    function index() {
        $this->load->library('design');
        $this->design->show();
    }
}

ERROR

Message: Undefined property: Design::$design

Filename: controllers/Design.php


if use

Code:
class Design extends CI_Controller {
    function __construct() {}
    function index() {
        $this->load->library('design_lib');
        $this->design_lib->show();
    }
}

no errors

This issue start after update from 2.2 to 3.0

How fix? We have big project(
Reply
#2

(This post was last modified: 06-03-2015, 01:22 PM by davicotico. Edit Reason: Fix )

Assign the Library to a different object name:


Code:
$this->load->library('design', NULL, 'my_design');
// Design class is now accessed using:
$this->my_design->show();

Reply
#3

It has nothing to do with the controller and library names. You're just overriding CI_Controller::__construct().
Reply
#4

Either get rid of your __construct() since you aren't doing anything with it, or it needs to call the parents __construct(). As Narf said, you're overriding it.
http://www.codeigniter.com/user_guide/ge...nstructors
Reply
#5

i paste this code only for example/

we use correct
Code:
function __construct() {
        parent::__construct();
}

the problem remains
Reply




Theme © iAndrew 2016 - Forum software by © MyBB