Answer the question
In order to leave comments, you need to log in
How to send a request to get rows from 3 tables at once to dataProvider?
First of all, I'm wondering if this is even possible.
The point is this. I have 3 tables somewhat different in their structure, but their essence is the same.
Right now I'm looking for records like this:
public function search($params)
{
$this->load($params);
if ($this->article_type == 2) {
$query = Journals::find()
->where(['journals.active' => self::ACTIVE])
->groupBy('journals.id');
} elseif ($this->article_type == 3) {
$query = Parks::find()
->joinWith('regionsParkRelation as rpr')
->groupBy('parks.id');
} else {
$query = Articles::findAll()
->joinWith('district')
->where(['active' => self::ACTIVE])
}
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
//.............
Answer the question
In order to leave comments, you need to log in
No, this will not work without adhesive tape and an ax, at best, you need to make a union and combine the request. But your data is completely different. In excel, you cannot even manually merge tables with different columns, and even their number.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question