Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel和SQL,其中或何处不';不限制_Php_Sql_Laravel - Fatal编程技术网

Php Laravel和SQL,其中或何处不';不限制

Php Laravel和SQL,其中或何处不';不限制,php,sql,laravel,Php,Sql,Laravel,我觉得这很简单,但让我有点疯狂 我有这个: Transaction:: where('seller_id', $this->id)-> Orwhere('buyer_id', $this->id )-> whereIn('concept', ['Lemonway','Paypal'])-> where('status', '=', 'ok') ->get(); 因此,如果我明确指定status='ok' 为什么选择一个

我觉得这很简单,但让我有点疯狂

我有这个:

Transaction::
    where('seller_id', $this->id)->
    Orwhere('buyer_id', $this->id )->
    whereIn('concept', ['Lemonway','Paypal'])->
    where('status', '=', 'ok')
    ->get();
因此,如果我明确指定
status='ok'

为什么选择一个
状态=挂起的交易

您需要使用参数分组,例如:

Transaction::where(function($q) {
        $q->where('seller_id', $this->id)
          ->orwhere('buyer_id', $this->id)
          ->whereIn('concept', ['Lemonway', 'Paypal']);
    })
    ->where('status', 'ok')
    ->get();

我对这种语法一无所知,但是('status'、'='、'ok')之前的三个where条件中的一个不可能导致status=Pending Transaction的行吗?运算符优先级是
NOT/和/或
,您的语法可能导致
(…)或status='ok'