From 468d16a24f2ecd07e922e158f541e9f6831636f2 Mon Sep 17 00:00:00 2001 From: Tomaz Lovrec Date: Fri, 16 Dec 2016 12:00:19 +0000 Subject: Remove needless constructor in model documentation PHP will execute the parent constructor regardless if a constructor method is defined in the child class or not. Defining an empty constructor just to call the parents constructor can be considered bad practice. --- user_guide_src/source/general/models.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/user_guide_src/source/general/models.rst b/user_guide_src/source/general/models.rst index 1cfe736de..08e9f5b30 100644 --- a/user_guide_src/source/general/models.rst +++ b/user_guide_src/source/general/models.rst @@ -22,12 +22,6 @@ model class might look like:: public $content; public $date; - public function __construct() - { - // Call the CI_Model constructor - parent::__construct(); - } - public function get_last_ten_entries() { $query = $this->db->get('entries', 10); -- cgit v1.2.3-24-g4f1b From 1398b72b32e3fb9628be2e09ffe97bea88565868 Mon Sep 17 00:00:00 2001 From: Tomaz Lovrec Date: Fri, 16 Dec 2016 12:02:12 +0000 Subject: Add constructor comments to match controller docs Empty constructors are pointless and bad practice, but removing them from this part of the documentation makes it less readable, makes less of a point, and would be quite frankly weird. Added a comment that suggests that further user code should be put there, like it is in the controller documentation --- user_guide_src/source/general/core_classes.rst | 1 + user_guide_src/source/general/models.rst | 2 ++ 2 files changed, 3 insertions(+) diff --git a/user_guide_src/source/general/core_classes.rst b/user_guide_src/source/general/core_classes.rst index 07c0b00ba..79f73ef06 100644 --- a/user_guide_src/source/general/core_classes.rst +++ b/user_guide_src/source/general/core_classes.rst @@ -101,6 +101,7 @@ your new class in your application controller's constructors. public function __construct() { parent::__construct(); + // Your own constructor code } public function index() diff --git a/user_guide_src/source/general/models.rst b/user_guide_src/source/general/models.rst index 08e9f5b30..eb842e927 100644 --- a/user_guide_src/source/general/models.rst +++ b/user_guide_src/source/general/models.rst @@ -70,6 +70,7 @@ The basic prototype for a model class is this:: public function __construct() { parent::__construct(); + // Your own constructor code } } @@ -85,6 +86,7 @@ The file name must match the class name. For example, if this is your class:: public function __construct() { parent::__construct(); + // Your own constructor code } } -- cgit v1.2.3-24-g4f1b