1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| $matField = "*" $matSql = Db::name('product') ->alias(['product' => 'p', 'match_goods' => 'b', 'match_goods_son' => 'c', 'area' => 'd']) ->field($matField) ->join('match_goods', 'b.product_id = p.product_id') ->join('match_goods_son', 'c.match_goods_id = b.match_goods_id') ->join('area', 'p.province = d.id') ->where($where) ->where(['p.type' => 3, 'p.status' => 2]) ->buildSql(); $actField = '*' $data = Db::field($actField) ->name('product') ->alias(['product' => 'p', 'activity_goods' => 'b', 'activity_goods_son' => 'c', 'area' => 'd']) ->join('activity_goods', 'b.product_id = p.product_id') ->join('activity_goods_son', 'c.activity_goods_id = b.activity_goods_id') ->join('area', 'p.province = d.id') ->where($where) ->where(['p.type' => 2, 'p.status' => 2]) ->union($matSql, true) ->select(false);
$sql = "($data)"; $res = Db::table($sql.' as a')->field('xx') ->order('a.sort DESC, a.sign_start_time DESC') ->group('a.product_id') ->page(1, 10) ->select()->toArray();
|