public function thirdInfo(){
return $this
->hasOne('third_info','id','wiid')->setEagerlyType(0) -> joinType('Left') ;
}
public function getList(){
$data = $this->with(['thirdInfo'=>function($q){$q->withField('appid');}]);
print_r($data->paginate(10)->toArray()) ;
}、5.1版本 hasone in查询可以 join查询报错
错误为:SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''
生成的sql语句为:SELECT COUNT(*) AS tp_count FROM `ar_product_ad_list` `ar_product_ad_list` LEFT JOIN `` `thirdInfo` ON `ar_product_ad_list`.`wiid`=`thirdInfo`.`id` LIMIT 1
最佳答案