Answer the question
In order to leave comments, you need to log in
How to get data and write it to a variable in Yii2?
I authorize on Yii2 created my own table, entered the data there. There, in a custom example, authorization from a variable that is equal to an array. I need to display data from the database and write it to the same array. How to do this I am new to php and OOP and Yii is my first framework.
That's why it doesn't workprivate static $users = self::find()->all();
Answer the question
In order to leave comments, you need to log in
And why reinvent the wheel, especially with a small amount of knowledge, authorization will most likely be full of holes. look towards ready-made solutions, for example, at the request of yii2-user
PS: in your example it is not clear where you call this and the name of the model (let it be /app/models/User for example)
then the call will be something like this:
private $users;
$this->users = Users::find()->all();
My opinion is still better to read a little oops
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question