Answer the question
In order to leave comments, you need to log in
What is the difference in calling model methods in Yii?
Hello everyone)
I fell into the hands of a site made on the first YII.
There is a Users.php file in the models folder. This file contains the funсName function (name for an example).
I see that it is accessed in two ways
app()->user->model->funcName() or Users::model()->funcName().
I think these are OOP features in PHP, not YII.
Explain, pliz, who knows?
Answer the question
In order to leave comments, you need to log in
:)
There is no difference, app()->user - this is the authManager component connected in the config, which is initialized when the application starts (opening the site page) and requires a user model, uses it for service purposes (relevant only for the User model), in the second case this is a standard reference that applies to any model in theory.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question