Answer the question
In order to leave comments, you need to log in
How to make a model for a custom query in Yii2?
Good afternoon!
This is probably not even a question, but a request for advice. There is a query that makes a selection from the database with the calculation of statistics. The query is rather complicated, and there are quite a lot of any fields in the list of returned fields ... SUM(`table`.`value`) AS `value_alias` ...
. Accordingly, there are no value_alias type fields in the table. It would not be desirable to fence representation (view) in a DB at all. Hence the question: How to work with the results like a query from the point of view of true yii2-way and how to construct such complex queries in general and then work with it as an object? Can be abstract or links.
Thanks in advance! :)
Answer the question
In order to leave comments, you need to log in
through the yii\base\DynamicModel model
for yii\base\Model
create in the current model public properties for alices $value_alias
Another way to name this in the request is the alias as well as the attribute . SUM(`table`.`value`) as value
Maybe I misunderstood, but in the model you can create fields that are not physically in the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question