Laravel 的查询修正

问题描述 投票:0回答:1

我正在使用此查询。

Safety::with( ['imageName'] )->where( ['property_id', '=', $property->property_id ], ['unit_id', '=', $property->unit_id ],['type','=', 'gas' ])->latest()->first();

我收到错误

SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'where clause' 

查询有问题吗?

php laravel where-clause
1个回答
0
投票

问题出在您的

where
条款中。将其合并到一个数组并尝试

Safety::with(['imageName'])
    ->where([
        ['property_id', '=', $property->property_id],
        ['unit_id', '=', $property->unit_id],
        ['type', '=', 'gas']
    ])
    ->latest()
    ->first();
© www.soinside.com 2019 - 2024. All rights reserved.