Codeigniter:如何在我的项目中使用多个'MY_Model'?

I am new to CI and I am maintaining one project build in CI, previously developed by another guy.

This guy create his own MY_Model in application/core and all models he created extend that MY_Model.

I don't like the core model built by him and want to use Jamie Rumbelow's MY_Model instead in the other models I will create recently.

But since almost all the old models extended the MY_Model already, I can't just replace MY_Model.

How can I use Jamie Rumbelow's MY_Model' and still make old models work?

Thanks for any advices!

You'd have to rename one of the MY_Model classes and put both of them in the MY_Model.php file (or include the renamed one from there). For example, if you were to rename Jamie Rumbelow's class to JR_Model instead, here's how your MY_Model.php file would look like:

class MY_Model extends CI_Model {
    // your predecessor's code
}

class JR_Model extends CI_Model {
    // Jamie Rumbelow's code
}

... then you can extend from JR_Model wherever you like, without breaking your old models.

Note that it's important to keep the filename as 'MY_Model.php', because that's what CodeIgniter will look for when loading a CI_Model extension.