S
S
Stepan2015-01-25 19:26:11
Yii
Stepan, 2015-01-25 19:26:11

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 work
private static $users = self::find()->all();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LIAL, 2015-01-25
@xoma2

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 question

Ask a Question

731 491 924 answers to any question