Answer the question
In order to leave comments, you need to log in
Why is it necessary to be so perverted in Yii2?
There is a request that works without problems
$query = News::find()
->select(['{{%news}}.id as nid','{{%news}}.`name` as `nname`', 'SUBSTRING({{%news}}.`text`, 1, 256 ) AS `ntext`', '{{%news}}.date', '{{%category}}.`id` AS catid','{{%category}}.`name` AS catname'])
->leftJoin('{{%category}}', '{{%category}}.id = {{%news}}.category_id')
->where($where['where'], $where['arr']);
Answer the question
In order to leave comments, you need to log in
And if you write a SQL query without a builder, won't you need to "rename the fields"?
Problem rather in "Why it is necessary so to be perverted in SQL?"
I don’t consider this a perversion myself, but I have come across such a solution: name fields in tables as news_id, news_name (in news) and category_id, category_name (in category). Well, in general, you understand, all fields are obtained with unique names;)
https://github.com/yiisoft/yii2/blob/master/docs/g...
Relational hasOne
or keep doing a bunch>.<
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question