Welcome Guest, Not a member yet? Register   Sign In
BaseController load, use model example
#2

There is a helper that you can use that makes it a lot simpler.

PHP Code:
// Create a new class manually
$userModel = new \App\Models\UserModel();

// Create a new class with the model function
$userModel model('App\Models\UserModel'false);

// Create a shared instance of the model
$userModel model('App\Models\UserModel');

// Create shared instance with a supplied database connection
// When no namespace is given, it will search through all namespaces
// the system knows about and attempt to located the UserModel class.
$db db_connect('custom');
$userModel model('UserModel'true$db); 

CodeIgniter 4 User Guide - Using CodeIgniter’s Model
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: BaseController load, use model example - by InsiteFX - 09-19-2020, 07:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB