Reputation: 337
I am confused, again, about implementing OOP in CodeIgniter.
By design, I have two classes, namely Customer and Supplier. Both classes extends a super class I call Institution.
It was not a problem for me when I wrote them using only php (without framework).
class Customer extends Institution {
public function __construct() {
parent::__construct();
}
}
class Supplier extends Institution {
public function __construct() {
parent::__construct();
}
}
class Institution extends DBConnection {
public function __construct() {
parent::__construct();
}
}
class DBConnection {
// do CRUD activities here
}
The questions are:
A friend suggested a way I thought a bit hacky, model extends model. I try, if possible, to do it in codeigniter-appropriate way.
Any suggestion will be appreciated.
Upvotes: 0
Views: 1253
Reputation: 26921
Well, as it is going to be your domain model entities, it should be models. And there is nothing wrong in having another model
class as a base class for model
class. So, you'll just need to make your Institution
(or DBConnection
if you prefer to keep it) class extend CI_Model
.
Upvotes: 1