P
P
Pepper12017-02-13 19:58:25
Yii
Pepper1, 2017-02-13 19:58:25

YII2 how to attach a table with a different name to a model?

Is it possible in YII2 to let's say Index model (website.ru/index.php pages) to bind, for example, a mysql table "user" to display a list of users on the main page. As far as I understand from the manual, the name of the table should correspond to the name of the model. Experiments did not give positive results. How to be?
ps The infection is hard...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-02-13
@slo_nik

Good evening.
Usually, it is customary to accompany such questions with your own code and error text, if any.
And I don't see the difficulty. Make a public, static method in the User model that will list all users.
And on the index page, you can call it like this:
or in the controller, then passing a variable to the view in which the result of the method will be.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question