|
@@ -92,8 +92,8 @@ func (this *Shop) load() *Shop {
|
|
main.alias,
|
|
main.alias,
|
|
main.lft,
|
|
main.lft,
|
|
main.rgt,
|
|
main.rgt,
|
|
- depth.depth,
|
|
|
|
- MAX(main.parent_id) AS parent_id
|
|
|
|
|
|
+ main.depth,
|
|
|
|
+ parent.id AS parent_id
|
|
FROM
|
|
FROM
|
|
(
|
|
(
|
|
SELECT
|
|
SELECT
|
|
@@ -103,20 +103,26 @@ func (this *Shop) load() *Shop {
|
|
node.alias,
|
|
node.alias,
|
|
node.lft,
|
|
node.lft,
|
|
node.rgt,
|
|
node.rgt,
|
|
- parent.id AS parent_id
|
|
|
|
|
|
+ (COUNT(parent.id) - 1) AS depth
|
|
FROM
|
|
FROM
|
|
shop_cats AS node,
|
|
shop_cats AS node,
|
|
shop_cats AS parent
|
|
shop_cats AS parent
|
|
WHERE
|
|
WHERE
|
|
- node.lft BETWEEN parent.lft AND parent.rgt AND
|
|
|
|
- node.id > 1
|
|
|
|
|
|
+ node.lft BETWEEN parent.lft AND parent.rgt
|
|
|
|
+ GROUP BY
|
|
|
|
+ node.id
|
|
ORDER BY
|
|
ORDER BY
|
|
node.lft ASC
|
|
node.lft ASC
|
|
) AS main
|
|
) AS main
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
SELECT
|
|
SELECT
|
|
node.id,
|
|
node.id,
|
|
- (COUNT(parent.id) - 1) AS depth
|
|
|
|
|
|
+ node.user,
|
|
|
|
+ node.name,
|
|
|
|
+ node.alias,
|
|
|
|
+ node.lft,
|
|
|
|
+ node.rgt,
|
|
|
|
+ (COUNT(parent.id) - 0) AS depth
|
|
FROM
|
|
FROM
|
|
shop_cats AS node,
|
|
shop_cats AS node,
|
|
shop_cats AS parent
|
|
shop_cats AS parent
|
|
@@ -126,12 +132,14 @@ func (this *Shop) load() *Shop {
|
|
node.id
|
|
node.id
|
|
ORDER BY
|
|
ORDER BY
|
|
node.lft ASC
|
|
node.lft ASC
|
|
- ) AS depth ON depth.id = main.id
|
|
|
|
|
|
+ ) AS parent ON
|
|
|
|
+ parent.depth = main.depth AND
|
|
|
|
+ main.lft > parent.lft AND
|
|
|
|
+ main.rgt < parent.rgt
|
|
WHERE
|
|
WHERE
|
|
- main.id > 1 AND
|
|
|
|
- main.id <> main.parent_id
|
|
|
|
- GROUP BY
|
|
|
|
- main.id
|
|
|
|
|
|
+ main.id > 1
|
|
|
|
+ ORDER BY
|
|
|
|
+ main.lft ASC
|
|
) AS cats ON cats.id = shop_products.category
|
|
) AS cats ON cats.id = shop_products.category
|
|
WHERE
|
|
WHERE
|
|
shop_products.active = 1
|
|
shop_products.active = 1
|
|
@@ -233,8 +241,8 @@ func (this *Shop) load() *Shop {
|
|
main.alias,
|
|
main.alias,
|
|
main.lft,
|
|
main.lft,
|
|
main.rgt,
|
|
main.rgt,
|
|
- depth.depth,
|
|
|
|
- MAX(main.parent_id) AS parent_id
|
|
|
|
|
|
+ main.depth,
|
|
|
|
+ parent.id AS parent_id
|
|
FROM
|
|
FROM
|
|
(
|
|
(
|
|
SELECT
|
|
SELECT
|
|
@@ -244,20 +252,26 @@ func (this *Shop) load() *Shop {
|
|
node.alias,
|
|
node.alias,
|
|
node.lft,
|
|
node.lft,
|
|
node.rgt,
|
|
node.rgt,
|
|
- parent.id AS parent_id
|
|
|
|
|
|
+ (COUNT(parent.id) - 1) AS depth
|
|
FROM
|
|
FROM
|
|
shop_cats AS node,
|
|
shop_cats AS node,
|
|
shop_cats AS parent
|
|
shop_cats AS parent
|
|
WHERE
|
|
WHERE
|
|
- node.lft BETWEEN parent.lft AND parent.rgt AND
|
|
|
|
- node.id > 1
|
|
|
|
|
|
+ node.lft BETWEEN parent.lft AND parent.rgt
|
|
|
|
+ GROUP BY
|
|
|
|
+ node.id
|
|
ORDER BY
|
|
ORDER BY
|
|
node.lft ASC
|
|
node.lft ASC
|
|
) AS main
|
|
) AS main
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
SELECT
|
|
SELECT
|
|
node.id,
|
|
node.id,
|
|
- (COUNT(parent.id) - 1) AS depth
|
|
|
|
|
|
+ node.user,
|
|
|
|
+ node.name,
|
|
|
|
+ node.alias,
|
|
|
|
+ node.lft,
|
|
|
|
+ node.rgt,
|
|
|
|
+ (COUNT(parent.id) - 0) AS depth
|
|
FROM
|
|
FROM
|
|
shop_cats AS node,
|
|
shop_cats AS node,
|
|
shop_cats AS parent
|
|
shop_cats AS parent
|
|
@@ -267,12 +281,14 @@ func (this *Shop) load() *Shop {
|
|
node.id
|
|
node.id
|
|
ORDER BY
|
|
ORDER BY
|
|
node.lft ASC
|
|
node.lft ASC
|
|
- ) AS depth ON depth.id = main.id
|
|
|
|
|
|
+ ) AS parent ON
|
|
|
|
+ parent.depth = main.depth AND
|
|
|
|
+ main.lft > parent.lft AND
|
|
|
|
+ main.rgt < parent.rgt
|
|
WHERE
|
|
WHERE
|
|
- main.id > 1 AND
|
|
|
|
- main.id <> main.parent_id
|
|
|
|
- GROUP BY
|
|
|
|
- main.id
|
|
|
|
|
|
+ main.id > 1
|
|
|
|
+ ORDER BY
|
|
|
|
+ main.lft ASC
|
|
) AS cats ON cats.id = shop_products.category
|
|
) AS cats ON cats.id = shop_products.category
|
|
WHERE
|
|
WHERE
|
|
shop_products.active = 1 AND
|
|
shop_products.active = 1 AND
|
|
@@ -566,8 +582,8 @@ func (this *Shop) Categories(parent, depth int) []*ShopCategory {
|
|
main.alias,
|
|
main.alias,
|
|
main.lft,
|
|
main.lft,
|
|
main.rgt,
|
|
main.rgt,
|
|
- depth.depth,
|
|
|
|
- MAX(main.parent_id) AS parent_id
|
|
|
|
|
|
+ main.depth,
|
|
|
|
+ parent.id AS parent_id
|
|
FROM
|
|
FROM
|
|
(
|
|
(
|
|
SELECT
|
|
SELECT
|
|
@@ -577,20 +593,26 @@ func (this *Shop) Categories(parent, depth int) []*ShopCategory {
|
|
node.alias,
|
|
node.alias,
|
|
node.lft,
|
|
node.lft,
|
|
node.rgt,
|
|
node.rgt,
|
|
- parent.id AS parent_id
|
|
|
|
|
|
+ (COUNT(parent.id) - 1) AS depth
|
|
FROM
|
|
FROM
|
|
shop_cats AS node,
|
|
shop_cats AS node,
|
|
shop_cats AS parent
|
|
shop_cats AS parent
|
|
WHERE
|
|
WHERE
|
|
- node.lft BETWEEN parent.lft AND parent.rgt AND
|
|
|
|
- node.id > 1
|
|
|
|
|
|
+ node.lft BETWEEN parent.lft AND parent.rgt
|
|
|
|
+ GROUP BY
|
|
|
|
+ node.id
|
|
ORDER BY
|
|
ORDER BY
|
|
node.lft ASC
|
|
node.lft ASC
|
|
) AS main
|
|
) AS main
|
|
LEFT JOIN (
|
|
LEFT JOIN (
|
|
SELECT
|
|
SELECT
|
|
node.id,
|
|
node.id,
|
|
- (COUNT(parent.id) - 1) AS depth
|
|
|
|
|
|
+ node.user,
|
|
|
|
+ node.name,
|
|
|
|
+ node.alias,
|
|
|
|
+ node.lft,
|
|
|
|
+ node.rgt,
|
|
|
|
+ (COUNT(parent.id) - 0) AS depth
|
|
FROM
|
|
FROM
|
|
shop_cats AS node,
|
|
shop_cats AS node,
|
|
shop_cats AS parent
|
|
shop_cats AS parent
|
|
@@ -600,12 +622,12 @@ func (this *Shop) Categories(parent, depth int) []*ShopCategory {
|
|
node.id
|
|
node.id
|
|
ORDER BY
|
|
ORDER BY
|
|
node.lft ASC
|
|
node.lft ASC
|
|
- ) AS depth ON depth.id = main.id
|
|
|
|
|
|
+ ) AS parent ON
|
|
|
|
+ parent.depth = main.depth AND
|
|
|
|
+ main.lft > parent.lft AND
|
|
|
|
+ main.rgt < parent.rgt
|
|
WHERE
|
|
WHERE
|
|
- main.id > 1 AND
|
|
|
|
- main.id <> main.parent_id
|
|
|
|
- GROUP BY
|
|
|
|
- main.id
|
|
|
|
|
|
+ main.id > 1
|
|
ORDER BY
|
|
ORDER BY
|
|
main.lft ASC
|
|
main.lft ASC
|
|
;
|
|
;
|