Welcome Guest, Not a member yet? Register   Sign In
Use new Model()

(This post was last modified: 12-10-2019, 07:01 AM by Myster.)

Hello, first of all sorry for my English I am French.

I would like to know how is it possible to use models like this:

$ var = new Model ();

Because I do not like $ this-> model-> method

I prefer to work as I use class with bookstores, I do not want to get lost with the models

For example for my class User I do:
require_once (APPPATH. 'libraries/User.php');

$ user = new User ();

I would like to do that for models but when I do
require_once (APPPATH. 'models/AuthTable.php');

$ table = new AuthTable ();

I have this error:
Message: Class 'CI_Model' not found

Thank you

Depending on how far along you are in your program, I would suggest you take a look at Codeigniter 4. It got support for namespaces and will autoload your models (and will work with new AuthTable(); )

PHP Code:

$model = new model_name(); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB