Welcome Guest, Not a member yet? Register   Sign In
Helpers loading with each include statement
#1

I have helpers that are loading site wide (menu stuff, message notifications, etc). I just noticed in the debugger that the helpers appear to be firing off on the initial page/view load and with each "include" within that view. Some helpers are database calls. This is causing the database to be hit 5-6 times PER PAGE for the exact same information. Is there a way to not have CI 4 repeatedly load a helper? The helpers are being loaded in the BaseController as they are needed on pretty much all pages (seemed a better solution that trying to remember to include in each individual controller):

Code:
protected $helpers = ["form", "auth", "phone", "text","siteinfo","state","number","money"];


For example this code:
PHP Code:
<?= $this->include('_partials/topbar'?>
 <?= $this->include('_partials/sidebar'?>
Results in:
Code:
SELECT COUNT(*) AS `numrows` FROM `lead_main` WHERE `status` != "Cancelled"
SELECT COUNT(*) AS `numrows` FROM `lead_main` WHERE `status` = "Future Prospect"
SELECT COUNT(*) AS `numrows` FROM `customer_main` WHERE `status_customer` != "Closed"
SELECT * FROM `todo` WHERE `assigned_to` = '1' AND `date_completed` IS NULL ORDER BY `date_due`
SELECT COUNT(*) AS `numrows` FROM `lead_main` WHERE `status` != "Cancelled"
SELECT COUNT(*) AS `numrows` FROM `lead_main` WHERE `status` = "Future Prospect"
SELECT COUNT(*) AS `numrows` FROM `customer_main` WHERE `status_customer` != "Closed"
SELECT * FROM `todo` WHERE `assigned_to` = '1' AND `date_completed` IS NULL ORDER BY `date_due`
Suggestions? Am I using the helpers incorrectly?
Reply


Messages In This Thread
Helpers loading with each include statement - by SoccerGuy3 - 08-09-2021, 02:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB