best practices? db call for every page - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: best practices? db call for every page (/showthread.php?tid=10234) |
best practices? db call for every page - El Forum - 07-23-2008 [eluser]chrisco23[/eluser] Hi, I need to make one db query to populate part of a navigation menu used on every page. I'd like to not put this in the view file, so currently I have the same 3 lines of code stuck into every controller. I'd like to not have to do this (and not have to remember to do this). What's a better way? Thanks, Chris best practices? db call for every page - El Forum - 07-23-2008 [eluser]beemr[/eluser] This thread covers your topic. best practices? db call for every page - El Forum - 07-23-2008 [eluser]Rick Jolly[/eluser] Yup, that thread outlines 2 good methods of reducing repetition: 1) controller inheritance 2) loading "modules" (view fragments with data) from within the view. best practices? db call for every page - El Forum - 07-23-2008 [eluser]chrisco23[/eluser] Thanks, I like the controller inheritance idea. Haven't really explored the "modules" stuff yet. Chris |