Does a model require that you extend the base model class? |
[eluser]dtrenz[/eluser]
I see in the documentation that a Controller only needs to extend the base class if you need to add code to the controllers constructor, but in the model docs it says that you always need to extend the base model class in your models. Is this required? And if so, why is it required in models and not in controllers?
[eluser]xwero[/eluser]
Where can did you find those lines? Every controller and model you make extends the base class. Code: class Customcontroller extends Controller {}
[eluser]Ebot Ndip-Agbor[/eluser]
[quote author="dtrenz" date="1205455012"]I see in the documentation that a Controller only needs to extend the base class...[/quote] i think i have never seen that in the user guide docs.
[eluser]dtrenz[/eluser]
http://ellislab.com/codeigniter/user-gui...ml#anatomy I think I misspoke. I'm actually asking if the constructor, the "parent::Model();" is required.
[eluser]xwero[/eluser]
You don't have to add it but then you would have to do your own checks to see it the model is already loaded or not.
[eluser]dtrenz[/eluser]
I don't understand what you mean. I thought that it was only required if I wanted to add my own code to the constructor.
[eluser]xwero[/eluser]
This is the model class Code: class Model { If the model class didn't have a role it would be silly to extend it.
[eluser]dtrenz[/eluser]
so this is only true of Models? Controller constructors are optional?
[eluser]xwero[/eluser]
The Controller constructor has another purpose. It comes down to the announcing of the controller to the application. If you don't add the Controller constructor you can't use any of the loaded CI libraries. try this Code: class test extends Controller
[eluser]dtrenz[/eluser]
that's funny, because i just pulled out the constructor out of all my controllers and everything works fine. the docs make it sound optional: http://ellislab.com/codeigniter/user-gui...nstructors |
Welcome Guest, Not a member yet? Register Sign In |