with 使用where查询 一直 报错未定义数组下标: 0

浏览:505 发布日期:2019/09/08 分类:求助交流 关键字: with
with 使用where查询 打印sql语句是正确的 但就是 一直 报错 未定义数组下标: 0 // 价格区间
        $price_where = $max_where = [];
        if (isset($json['section'])) {
            $min_money = $json['section']['min'];
            $max_money = $json['section']['max'];
            if ($min_money >= 0 ) {
                $price_where["goods_price"] = ['egt',$min_money];
            }
            if ($max_money > 0) {
                $price_where["goods_price"] = ['elt',$max_money];
            }
        }

        // 执行查询
        $list = $this
            ->field(['*', '(sales_initial + sales_actual) as goods_sales',
                "$minPriceSql AS goods_min_price",
                "$maxPriceSql AS goods_max_price"
            ])
            ->with(['category','image.file',
                'sku' => function($query) use ($price_where) {
                    if (!empty($price_where)) {
                        $query->where($price_where);
                    }
                }
            ])
            ->where('is_delete', '=', 0)
            ->where($filter)
            ->order($sort)
            ->paginate($params['listRows'], false, [
                'query' => \request()->request()
            ]);

         echo $this->getLastSql();
最佳答案
评论( 相关
后面还有条评论,点击查看>>