Codeigniter and Multiple Inheritance? Codeigniter and Multiple Inheritance? codeigniter codeigniter

Codeigniter and Multiple Inheritance?


Multiple inheritance is not possible. You either can use interfaces or you can use the visitor designpattern like this:

<?phpclass A {    public $avar = 'I\'m A';    function accept(Visitor $v){        $v->visitA($this);    }}class B {    public $bvar = 'B reporting';    function accept(Visitor $v){        $v->visitB($this);    }}class Visitor {    function visitA(A $a){        echo $a->avar;    }    function visitB(B $b){        echo $b->bvar;    }}$A = new A();$B = new B();$visitor = new Visitor();$A->accept($visitor);$B->accept($visitor);?>

unfortunately php is not ready yet for distinguishing method calls by their parameter like in java where this example would look like that:

class A {    public String avar = 'I\'m A';    function accept(Visitor v){        v.visit(this);    }}class B {    public String bvar = 'B reporting';    function accept(Visitor v){        v.visit(this);    }}class Visitor {    function visit(A a){        System.out.println(a.avar);    }    function visit(B b){        System.out.println(b.bvar);    }}A = new A();B = new B();visitor = new Visitor();A.accept(visitor);B.accept(visitor);

where you have multiple visit methods distinguished by the type of their parameters


Multiple inheritance is not possible with PHP. I'm wondering though, why would you need two separate login controllers? Could you explain what you're doing in the controllers?

EDIT:
Not sure if your code allows this, but you could try putting all general parts in the client controller and let the admin controller extend from this one.

X -> Admin Ctrlr -> Client Ctrlr -> YX -> Client Ctrlr -> Y


I don't see where is the multiple inheritance there.

I'm also working with codeigniter, and I had the need to subclass it's Controller so all my Controllers can descend from mine and not from CodeIgniter's directly.

CodeIgniter has native methods for extending it's classes with your own. Or you could open the model.php file (in system/libraries/) and at the top of the file, right after the if (!defined ...), you could add the code of your ManageModel class

Also here's a link for extending the model http://www.askaboutphp.com/50/codeigniter-extending-the-native-model-and-make-it-your-own.html