Old way of using classes and CI's way - Confused |
I have been trying to improve my code by sticking to OOP concepts. As you can see below my code is using a user class and passing that user class to the models class.
In code igniter it would be done like this, but this isn't the case since it just gives me an error because of the parameters. PHP Code: $this->load->library('User'); My code below: PHP Code: $params = array('forename' => $_forename, 'surname' => $_surname, 'dob' => $_dob, 'address' => $_address, 'telephone' => $_telephone, 'email' => $_email, 'password' => $_password);
CI3 wants classes to be named UCfirst, i.e. $this->load->model('User_model'), and with the source code in models/User_model.php.
Once loaded, the model is available as a property, eg $this->user_model, without having to instantiate it. Your naming confuses me ... I would think that models/User.php would *be* a model for a user. I might use something like models/Users for the "model" (collection) and models/User for the "entity".
(12-27-2018, 05:14 PM)ciadmin Wrote: CI3 wants classes to be named UCfirst, i.e. $this->load->model('User_model'), and with the source code in models/User_model.php. |
Welcome Guest, Not a member yet? Register Sign In |