Does the model have to be instantiated when using the model in the TP5 controller?

for example, there is a getuid () method in the User model. For example, do I have to instantiate the User model first when I want to use the method in the controller? $user=new User () and then call this $user- > getuid () method?

Mar.11,2021

you can use the helper function Model ('User')-> getuid ();


can be set to a static method

public static function getuid()
{
...
}

then call

statically
$uid = User::getuid();

non-static methods must of course be instantiated first


within the current model $uid = self- > getuid ();

Menu