Skip to content

Commit 4b866e8

Browse files
committed
Added filter by subscription_plan_id
1 parent 0ed66bf commit 4b866e8

6 files changed

+42
-14
lines changed

admin/sql/mysqli/product_subscription.sql

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
BEGIN
1515
-- product_subscription
1616
SELECT
17-
sp.*,
18-
spc.name,
17+
@IF isset(:product_id)
18+
THEN
19+
sp.*,
20+
spc.name,
21+
END @IF
1922
product_subscription.product_id,
2023
product_subscription.user_group_id,
2124
product_subscription.price,

admin/sql/mysqli/subscription_plan.sql

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@
44

55
PROCEDURE getAll(
66
IN language_id INT,
7+
IN subscription_plan_id ARRAY,
78
IN start INT,
89
IN limit INT,
910
OUT fetch_all,
1011
OUT fetch_one,
1112
)
1213
BEGIN
1314
-- subscription_plan
14-
SELECT subscription_plan.*,subscription_plan_content.name
15+
SELECT subscription_plan.*,subscription_plan_content.name,subscription_plan.subscription_plan_id as array_key
1516
FROM subscription_plan AS subscription_plan
1617
INNER JOIN subscription_plan_content ON subscription_plan_content.subscription_plan_id = subscription_plan.subscription_plan_id
1718
AND subscription_plan_content.language_id = :language_id
1819
WHERE 1 = 1
19-
20+
21+
@IF isset(:subscription_plan_id)
22+
THEN
23+
AND subscription_plan.subscription_plan_id IN (:subscription_plan_id)
24+
END @IF
25+
2026
-- limit
2127
@IF isset(:limit)
2228
THEN

admin/sql/pgsql/product_subscription.sql

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
BEGIN
1515
-- product_subscription
1616
SELECT
17-
sp.*,
18-
spc.name,
17+
@IF isset(:product_id)
18+
THEN
19+
sp.*,
20+
spc.name,
21+
END @IF
1922
product_subscription.product_id,
2023
product_subscription.user_group_id,
2124
product_subscription.price,

admin/sql/pgsql/subscription_plan.sql

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@
44

55
PROCEDURE getAll(
66
IN language_id INT,
7+
IN subscription_plan_id ARRAY,
78
IN start INT,
89
IN limit INT,
910
OUT fetch_all,
1011
OUT fetch_one,
1112
)
1213
BEGIN
1314
-- subscription_plan
14-
SELECT subscription_plan.*,subscription_plan_content.name
15+
SELECT subscription_plan.*,subscription_plan_content.name,subscription_plan.subscription_plan_id as array_key
1516
FROM subscription_plan AS subscription_plan
1617
INNER JOIN subscription_plan_content ON subscription_plan_content.subscription_plan_id = subscription_plan.subscription_plan_id
1718
AND subscription_plan_content.language_id = :language_id
1819
WHERE 1 = 1
19-
20+
21+
@IF isset(:subscription_plan_id)
22+
THEN
23+
AND subscription_plan.subscription_plan_id IN (:subscription_plan_id)
24+
END @IF
25+
2026
-- limit
2127
@IF isset(:limit)
2228
THEN
@@ -29,7 +35,7 @@
2935

3036
) as count;
3137

32-
END
38+
END
3339

3440
-- get subscription plan
3541

@@ -58,6 +64,7 @@
5864
-- allow only table fields and set defaults for missing values
5965
:subscription_plan_data = @FILTER(:subscription_plan, subscription_plan)
6066

67+
6168
INSERT INTO subscription_plan
6269

6370
( @KEYS(:subscription_plan_data) )

admin/sql/sqlite/product_subscription.sql

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
BEGIN
1515
-- product_subscription
1616
SELECT
17-
sp.*,
18-
spc.name,
17+
@IF isset(:product_id)
18+
THEN
19+
sp.*,
20+
spc.name,
21+
END @IF
1922
product_subscription.product_id,
2023
product_subscription.user_group_id,
2124
product_subscription.price,

admin/sql/sqlite/subscription_plan.sql

+9-3
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@
44

55
PROCEDURE getAll(
66
IN language_id INT,
7+
IN subscription_plan_id ARRAY,
78
IN start INT,
89
IN limit INT,
910
OUT fetch_all,
1011
OUT fetch_one,
1112
)
1213
BEGIN
1314
-- subscription_plan
14-
SELECT subscription_plan.*,subscription_plan_content.name
15+
SELECT subscription_plan.*,subscription_plan_content.name,subscription_plan.subscription_plan_id as array_key
1516
FROM subscription_plan AS subscription_plan
1617
INNER JOIN subscription_plan_content ON subscription_plan_content.subscription_plan_id = subscription_plan.subscription_plan_id
1718
AND subscription_plan_content.language_id = :language_id
1819
WHERE 1 = 1
19-
20+
21+
@IF isset(:subscription_plan_id)
22+
THEN
23+
AND subscription_plan.subscription_plan_id IN (:subscription_plan_id)
24+
END @IF
25+
2026
-- limit
2127
@IF isset(:limit)
2228
THEN
@@ -29,7 +35,7 @@
2935

3036
) as count;
3137

32-
END
38+
END
3339

3440
-- get subscription plan
3541

0 commit comments

Comments
 (0)