在thinkphp 5.1 中 where 查询的特殊用法

    public function revokeOrderTransaction($orderId, $userId)
    {
        //检查是否是卖家 或者是买家
        $isBuyer = $this->order->where(['id' => $orderId, 'user_id' => $userId])->find();
        $isSeller = $this->order->where(['id' => $orderId, 'order_user_id' => $userId])->find();
        if (!$isBuyer && !$isSeller) {
            return $this->fail("没有相关权限");
        } else {
            //____________
            $this->order->where('id', $orderId)->where("user_id|order_user_id",$userId)->update(['status' => -1]);
            //___________
            return $this->success("撤销成功");
        }
    }



//    $this->order->where('id', $orderId)->where("user_id|order_user_id",$userId)->update(['status' => -1]);   等价于  
         $isBuyer = $this->order->where(['id' => $orderId, 'user_id' => $userId])->find();
        $isSeller = $this->order->where(['id' => $orderId, 'order_user_id' => $userId])->find();

你可能感兴趣的:(java,前端,javascript)