when to use parent::__construct(); in the class? |
[eluser]Unknown[/eluser]
Dear all I`ve started learning CI by the tutorial in the User Guide. I found the News_model did not add the parent::__construct() Code: News_model extends CI_Model { Code: class News extends CI_Controller { And whats the criteria of adding the parent::__construct() when creating the class? Many thanks
[eluser]CroNiX[/eluser]
You only need to add parent::__construct(), if you are doing something in your __construct(). just having Code: public function __construct() with nothing else doesn't do anything. See: http://ellislab.com/codeigniter/user-gui...nstructors
[eluser]Bart v B[/eluser]
In other words, if you are planning to do things only in that object, then you can reference that in your constructor.
[eluser]jairoh_[/eluser]
to inherit directly the attributes of the parent class. |
Welcome Guest, Not a member yet? Register Sign In |