【求助】一对一关联中join方式

浏览:767 发布日期:2018/06/28 分类:ThinkPHP5专区 关键字: 一对一关联
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
最佳答案
评论( 相关
后面还有条评论,点击查看>>