Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question