3
I have the following code:
class MY_Controller extends CI_Controller {
function __construct() {
parent::__construct();
}
}
I need to build a class where I do the Ci_controller extension, so I don’t have to "repeat" functions that are used throughout the system... For example: I have a model of clients, and another of employees, both use a function called getById(), I would like to not have to repeat the function and always leave them inside a main controller... To be better organized.
getById()
is in the model or controller? this method will have some standard implementation?– rray
It stays on all models of the system, but as it is a standard, I want to leave it on a controller only, and call when I need it... so with the other functions I have
– Sr. André Baill
@rray I wish I had a file where I concentrated all the functions that are needed in the system, which are standard, without I need to copy and paste the function in each model. Did you understand?
– Sr. André Baill
Depending on the case you can create a library for this, or make your model implement a
interface
crud, which would have the methods, save(), listAll(), find(), delete() etc.– rray
Yes, just this idea of mine... have a part, so I call when I need to use.
– Sr. André Baill