File tree 7 files changed +40
-20
lines changed
7 files changed +40
-20
lines changed Original file line number Diff line number Diff line change 172
172
LEFT JOIN post p ON (pc .post_id = p .post_id )
173
173
LEFT JOIN post_to_taxonomy_item ptt ON (ptt .taxonomy_item_id = @taxonomy_item_id AND ptt .post_id = p .post_id )
174
174
WHERE ptt .taxonomy_item_id = @taxonomy_item_id ORDER by p .sort_order
175
- ) AS posts
175
+ ) AS post
176
176
177
177
FROM taxonomy_item AS categories
178
178
Original file line number Diff line number Diff line change 1
1
-- Menus
2
-
2
+
3
3
-- get menu
4
4
5
5
CREATE PROCEDURE getMenu(
96
96
IN language_id INT ,
97
97
IN menu_id INT ,
98
98
IN site_id INT ,
99
- IN post_id INT ,
100
- IN search CHAR ,
101
99
IN type CHAR ,
102
100
103
101
-- pagination
113
111
114
112
SELECT * , menu .menu_id as array_key
115
113
116
- FROM menu
114
+ FROM menu
115
+
116
+ @IF isset(:menu_id)
117
+ THEN
118
+ WHERE menu .menu_id IN (:menu_id)
119
+ END @IF
120
+
121
+ -- limit
122
+ @IF isset(:limit )
123
+ THEN
124
+ @SQL_LIMIT(:start, :limit )
125
+ END @IF;
117
126
118
127
119
- @SQL_LIMIT(:start, :limit );
120
-
121
128
SELECT count (* ) FROM (
122
129
123
130
@SQL_COUNT(menu .menu_id , menu) -- this takes previous query removes limit and replaces select columns with parameter menu_id
Original file line number Diff line number Diff line change 171
171
LEFT JOIN post p ON (pc .post_id = p .post_id )
172
172
LEFT JOIN post_to_taxonomy_item ptt ON (ptt .taxonomy_item_id = categories .taxonomy_item_id AND ptt .post_id = p .post_id )
173
173
WHERE ptt .taxonomy_item_id = categories .taxonomy_item_id ORDER by p .sort_order
174
- ) AS posts
174
+ ) AS post
175
175
176
176
FROM taxonomy_item AS categories
177
177
Original file line number Diff line number Diff line change 96
96
IN language_id INT ,
97
97
IN menu_id INT ,
98
98
IN site_id INT ,
99
- IN post_id INT ,
100
- IN search CHAR ,
101
99
IN type CHAR ,
102
100
103
101
-- pagination
115
113
116
114
FROM menu
117
115
116
+ @IF isset(:menu_id)
117
+ THEN
118
+ WHERE menu .menu_id IN (:menu_id)
119
+ END @IF
118
120
119
- @SQL_LIMIT(:start, :limit );
121
+ -- limit
122
+ @IF isset(:limit )
123
+ THEN
124
+ @SQL_LIMIT(:start, :limit )
125
+ END @IF;
126
+
120
127
121
128
SELECT count (* ) FROM (
122
129
Original file line number Diff line number Diff line change 171
171
LEFT JOIN post p ON (pc .post_id = p .post_id )
172
172
LEFT JOIN post_to_taxonomy_item ptt ON (ptt .taxonomy_item_id = categories .taxonomy_item_id AND ptt .post_id = p .post_id )
173
173
WHERE ptt .taxonomy_item_id = categories .taxonomy_item_id ORDER by p .sort_order
174
- ) AS posts
174
+ ) AS post
175
175
176
176
FROM taxonomy_item AS categories
177
177
Original file line number Diff line number Diff line change 96
96
IN language_id INT ,
97
97
IN menu_id INT ,
98
98
IN site_id INT ,
99
- IN post_id INT ,
100
- IN search CHAR ,
101
99
IN type CHAR ,
102
100
103
101
-- pagination
115
113
116
114
FROM menu
117
115
116
+ @IF isset(:menu_id)
117
+ THEN
118
+ WHERE menu .menu_id IN (:menu_id)
119
+ END @IF
118
120
119
- @SQL_LIMIT(:start, :limit );
121
+ -- limit
122
+ @IF isset(:limit )
123
+ THEN
124
+ @SQL_LIMIT(:start, :limit )
125
+ END @IF;
126
+
120
127
121
128
SELECT count (* ) FROM (
122
129
Original file line number Diff line number Diff line change @@ -58,7 +58,6 @@ function results() {
58
58
59
59
break ;
60
60
}
61
-
62
61
//count the number of child categories (subcategories) for each category
63
62
if (isset ($ results ['categories ' ])) {
64
63
foreach ($ results ['categories ' ] as $ taxonomy_item_id => &$ category ) {
@@ -74,11 +73,11 @@ function results() {
74
73
$ category ['children ' ] = 0 ;
75
74
}
76
75
77
- if (isset ($ category ['posts ' ]) && $ category ['posts ' ] && $ category ['posts ' ][0 ] = '[ ' ) {
78
- $ category ['posts ' ] = json_decode ($ category ['posts ' ], true );
76
+ if (isset ($ category ['post ' ]) && $ category ['post ' ] && $ category ['post ' ][0 ] = '[ ' ) {
77
+ $ category ['post ' ] = json_decode ($ category ['post ' ], true );
79
78
80
- if (is_array ($ category ['posts ' ])) {
81
- $ category ['posts_count ' ] = count ($ category ['posts ' ]);
79
+ if (is_array ($ category ['post ' ])) {
80
+ $ category ['posts_count ' ] = count ($ category ['post ' ]);
82
81
}
83
82
}
84
83
You can’t perform that action at this time.
0 commit comments