How to load Model? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31) +--- Thread: How to load Model? (/showthread.php?tid=66611) |
How to load Model? - startbbs - 11-11-2016 Code: $usermodel = new \App\Models\UserModel(); Code: $usermodel = new UserModel(); are they the same? which one is correct? thanks RE: How to load Model? - kilishan - 11-11-2016 They are only the same if you have declared the model at the top of the file: Code: <?php namespace App\Controllers; Otherwise you'll get an error. If you haven't used them before, running through a quick crash course on namespaces would be very helpful. |