关联预载入不支持 条件查询 ?

浏览:912 发布日期:2017/01/09 分类:ThinkPHP5专区
我有两个model类:User 与 UserProfile 我在User中加了一对一关联:  public function profile()
    {
        return $this->hasOne('UserProfile', 'id', 'id');
    }
我要使用关联查询

官方的例子:User::with('profile')->select([1,2,3]);但是我需要加入条件查询:User::with('profile')->where(['create_time'=>18311225421])->select();这种就报错了:SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'create_time' in where clause is ambiguous原因是两个表里都有 create_time 字段,我传入条件的时候没有指明,但是框架底层不会自动判断?
问题:我写的方式不对,还是关联预载入就不支持条件查询?
最佳答案
评论( 相关
后面还有条评论,点击查看>>