Welcome Guest, Not a member yet? Register   Sign In
Accessing a model in a much used helper
#1

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
{
    $textModel = new TextModel();

    return $textModel->getText($textName);

Reply
#2

Can you return the whole array and use it? What does "getText()"? I think for more abstraction we need more code.
Reply
#3

You can use the model() function to work with a single instance of a model class.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB