• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use new Model()

#1
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
Reply

#2
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(); )
Reply

#3
PHP Code:
$this->load->model('model_name');

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

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.