Extending Multiple models in Codeigniter 2?

As I said in this question about the controllers you just put both classes in the same MY_Model file. This file is used as part of the autoload feature of codeigniter, meaning that it will look for any files with the MY_ (or config defined) prefix.

As I said in this question about the controllers you just put both classes in the same MY_Model file. This file is used as part of the autoload feature of codeigniter, meaning that it will look for any files with the MY_ (or config defined) prefix. You don't even need to call the class inside MY_Model you can potentially call it MY_Special_Model and have MY_Another_Model directly underneath.

This is exactly what I do! It's not pretty because I like having each class in a separate file ... but it's the only way I could achieve this in CI. – MikeMurko Nov 17 '11 at 17:29 @MikeMurko There is way to have separate classes in separate files, but it involve making a custom loader class and isn't worth the time and effort.

– Cubed Eye Nov 17 '11 at 22:34.

I've tried Cubed Eye's way, and it works, but here's another option: Try adding a model to your autoload. Php file. It could inherit from MY_Model (which inherits from CI_Model), and any additional models you load could inherit from it: class Extended_model extends MY_Model { public function __construct() { parent::__construct(); $this->load->model('Another_model'); } } (models/Extended_model.

Php) class Another_model extends Extended_model { } (models/Another_model. Php) EDIT: I just realized that you're putting your extended model in the "core" folder. This is only necessary for classes that extend the core CI_* classes (i.e.

MY_Controller, MY_Model, MY_Input, etc. ). If you have a model extends MY_Model, put it in your models/ folder instead, and don't prefix it with "MY_".

Even though I have accepted the above answer, I have voted this up as I like having separate files per model, instead of stuffing them all in one file. – Rooneyl Nov 15 '11 at 14:23.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions