Accessing a model in a much used helper - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: Accessing a model in a much used helper (/showthread.php?tid=81058) |
Accessing a model in a much used helper - sjender - 01-19-2022 Hi all, I have this helper function which gets texts from a database to show on the website. But I wonder if this can be optimized in terms of efficiency. The getSiteText() function can be called many times on a single page. Do I really need to call the TextModel every single time, or are there better ways? PHP Code: function getSiteText(string $textName): string RE: Accessing a model in a much used helper - sprhld - 01-21-2022 Can you return the whole array and use it? What does "getText()"? I think for more abstraction we need more code. RE: Accessing a model in a much used helper - iRedds - 01-21-2022 You can use the model() function to work with a single instance of a model class. |