0
我學習Yii2,上市的時候我用自定義查詢列表我得到錯誤:得到錯誤而Yii2
The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.
我從查詢中獲取數據,但是當我把數據提供程序它給我的錯誤。這裏是我的代碼:
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;
}
誰能告訴我該怎麼做與自定義查詢上市?
可能的[Yii2 RESTful關係數據]重複(http://stackoverflow.com/questions/28122559/yii2-restful-relational-data) – Armfoot
@Armfoot是的,除了數據提供者的使用情況外,它有點類似。 – arogachev