03-19-2017, 02:50 PM
(02-02-2017, 10:42 PM)kilishan Wrote: In CI4, you don't autoload things in the same way as previous versions, since we now have a PSR4-compliant autoloader built in. As per the docs, whenever you need a database connection, you simply grab it:
$db = \Config\Database::connect();
You can do that in your controller constructor, if you like to have it available for every method. Or in a BaseController that your controllers extend from.
I use a lot CI , looking now to CI4 ... I clearly understand I can connect by adding this in the controller constructor. But I want to connect db only one time for my whole app. Somewhere like a general autoload for the connect db
if Someone can tell me where I can do that like in the "old" CI.
Thanks by advance.