Reputation: 3
I want to create 2 different models extends
CI_Model
in core folder,
for example:
class MY_FirsModel extends CI_Model {
}
class MY_SecondModel extends CI_Model {
}
Is it possible when using codeigniter?
Upvotes: 0
Views: 1383
Reputation: 687
According to Codeigniter's Documentation, when extending a core class, you need to give the same name to your class, only changing CI_
by MY_
.
When the loader class is fetching all core classes it looks for specific matching names such as Model
, Controller
, Exceptions
and so on. It starts looking by the application/core
folder, with prefixes MY_
and then goes to system/core
if a extended class was not found.
If you need to maintain the names MY_FirsModel
and MY_SecondModel
, you can create these models in the application/libraries
folder and the require these files in the classes you will use them.
require_once APPPATH.'libraries/MY_FirsModel.php';
and
require_once APPPATH.'libraries/MY_SecondModel.php';
Upvotes: 1
Reputation: 1
it is possible to have it like that way. This will going to work. I read it once on CI forum
(I don't remember the exact link as it's been long time) that some admins like to use this kind of style but many people are in favor of separating them into 2 different file
Upvotes: 0