I am learning Yii2, when I do listing with custom query I am getting error:
The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.
I am getting data from query but when I put in dataprovider it is giving me error. Here is my code:
public function search($params) {
//$query = User::find();
$query = new \yii\db\Query;
$query = $query->select(['user.*','tbl_region.id','tbl_region.regionName'])
->from('user')
->join('LEFT JOIN','tbl_men_reg_info','tbl_men_reg_info.userID = user.id')
->join('LEFT JOIN','tbl_women_info','tbl_women_info.userID = user.id')
->join('LEFT JOIN','tbl_region','tbl_men_reg_info.region = tbl_region.id');
$command = $query->createCommand();
$query = $command->queryAll();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
return $dataProvider;
}
Can anyone please tell me how to do listing with custom query?