Am trying to combine data from different queries into a single active record for the purpose of pagination
I have two different databases with similar table, that is
db1
tbl_products
id,quantity,price
Now on db2
db2
tbl_products
id,quantity,price
SO i have two models with different connections where first model connects to db1 and second to db2
class ProductsDb1 extends ActiveRecord{
public static function getDb()
{
return 'db1'
}
}
class ProductsDb2 extends ActiveRecord{
public static function getDb()
{
return 'db2'
}
}
SO now in my current query i have
$db1productsQuery = ProductsDb1::find()->where(...)
$db2productsQuery = ProductsDb2::find()->where(...);
On my ActiveDataProvider am passing my query like
$data = new ActiveDataProvider([
'query' => $db1productsQuery, //pass the dbproducts query
'sort' => ['defaultOrder' => ['quantity' => SORT_DESC]],
'pagination' => [
'pageSize' => $arr['perPage'],
'page' => $arr['page']
],
]);
As from the above i have to create multiple activeDataProviders for each query and return data separately. Is it possible to combine or add both queries to a single ActiveDataProvider rather than having to create each data provider for each query