Thinkphp5 multi-field unique query

[
    [
        "goods_id" => 1,
        "attr_item" => "49,52"
    ], [
        "goods_id" => 1,
        "attr_item" => "49,51"
    ]
]

I would like to query such a condition goods_id=1 & & attr_item = = "49 attr_item 52 | | goods_id=1 & & attr_item = =" 49 attr_item 51 "
how to write the uniqueness of multi-field composition

Php
Apr.08,2022

query with closures

$result = Db::table('think_user')->where(function ($query) {
    $query->where('id', 1)->whereOr('id', 2);
})->whereOr(function ($query) {
    $query->where('name', 'like', 'think')->whereOr('name', 'like', 'thinkphp');
})->select();

generates a sql statement similar to the following

SELECT * FROM `think_user` WHERE  (  `id` = 1 OR `id` = 2 ) OR (  `name` LIKE 'think' OR `name` LIKE 'thinkphp' )
Menu