Welcome Guest, Not a member yet? Register   Sign In
Name requirement of Controller and Model is different when extending core lib
#1

(This post was last modified: 09-16-2016, 09:00 PM by dangyuluo.)

I'm trying to extend the original CI_Controller and CI_Model to meet some of my demands. But when I do this, I found that the name requirement of extending these two core libraries is different from each other.

First, I created a file called MY_Controller.php in /application/core, and then create a class whose name does not start with the default required "MY_":
PHP Code:
class A_Controller extends CI_Controller {
public function 
__construct()
    {}


You see, though I did not meet the naming requirement (which can be seen here Creating core libraries), it actually works.

But it behaves differently when extending CI_Model. If my MY_Model.php is like this:
PHP Code:
class A_Model extends CI_Model {
public function 
__construct()
    {}


Codeigniter will throw an error telling me that:
Code:
Message: /var/www/application/core/MY_Model.php exists, but doesn't declare class MY_Model

So is the naming strategy of extending CI_Controller and CI_Molde treated differently ?
Reply
#2

Look at the CI ./system/core/Loader.php
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB