SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘id’ in ‘where clause’

模型关联查询,要查询的字段出现在多个模型中的话,需要支出模型的名称,当前模型也是有名字的,写模型的名字就行
比如 $where_two['user.id']=['=',$row['pid']];//要携带模型名称

场景如下:

$list = $this->model
    ->where($where_two)
    ->where($where)
    ->with('group')
    ->with('scanprizelog')
    ->order($sort, $order)
    ->paginate($limit);

只要正确支出模型名称,问题就解决了

阅读剩余
THE END