Skip to content

Commit 28e6e74

Browse files
committed
Removed unnecessary 'table AS table' from queries
1 parent 9ae07b1 commit 28e6e74

File tree

159 files changed

+555
-461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+555
-461
lines changed

admin/sql/mysqli/admin.sql

+19-19
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818
BEGIN
1919

20-
SELECT * FROM admin AS admin WHERE 1 = 1
20+
SELECT * FROM admin WHERE 1 = 1
2121

2222

2323
@IF isset(:status) AND !empty(:status)
@@ -76,36 +76,36 @@
7676

7777
WHERE 1 = 1
7878

79-
@IF isset(:username)
80-
THEN
81-
AND _.username = :username
82-
END @IF
79+
@IF isset(:username)
80+
THEN
81+
AND _.username = :username
82+
END @IF
8383

84-
@IF isset(:email)
85-
THEN
86-
AND _.email = :email
87-
END @IF
84+
@IF isset(:email)
85+
THEN
86+
AND _.email = :email
87+
END @IF
8888

89-
@IF isset(:admin_id)
89+
@IF isset(:admin_id)
9090
THEN
9191
AND _.admin_id = :admin_id
92-
END @IF
92+
END @IF
9393

94-
@IF isset(:status)
94+
@IF isset(:status)
9595
THEN
9696
AND _.status = :status
97-
END @IF
98-
97+
END @IF
98+
9999
@IF isset(:token)
100100
THEN
101101
AND _.token = :token
102-
END @IF
103-
104-
@IF isset(:role_id)
102+
END @IF
103+
104+
@IF isset(:role_id)
105105
THEN
106106
AND _.role_id = :role_id
107-
END @IF
108-
107+
END @IF
108+
109109
LIMIT 1;
110110

111111
END

admin/sql/mysqli/attribute.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
,pa.value
2121
END @IF
2222

23-
FROM attribute AS attribute
23+
FROM attribute
2424
INNER JOIN attribute_content
2525
ON attribute_content.attribute_id = attribute.attribute_id AND attribute_content.language_id = :language_id
2626
INNER JOIN attribute_group_content

admin/sql/mysqli/attribute_group.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
,pa.value
1919
END @IF
2020

21-
FROM attribute_group AS attribute_group
21+
FROM attribute_group
2222
INNER JOIN attribute_group_content
2323
ON attribute_group_content.attribute_group_id = attribute_group.attribute_group_id AND attribute_group_content.language_id = :language_id
2424

admin/sql/mysqli/comment.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
,post_content.name, post_content.slug
3030
END @IF
3131

32-
FROM comment AS comment
32+
FROM comment
3333
LEFT JOIN user ON (user.user_id = comment.user_id)
3434

3535
@IF isset(:post_title) AND :post_title

admin/sql/mysqli/country.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
BEGIN
1414
-- country
1515
SELECT *
16-
FROM country AS country WHERE 1 = 1
16+
FROM country WHERE 1 = 1
1717

1818
@IF isset(:status) AND :status != ""
1919
THEN

admin/sql/mysqli/coupon.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
BEGIN
1313
-- coupon
1414
SELECT *
15-
FROM coupon AS coupon WHERE 1 = 1
15+
FROM coupon WHERE 1 = 1
1616

1717

1818
@SQL_LIMIT(:start, :limit);

admin/sql/mysqli/currency.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
BEGIN
1212
-- currency
1313
SELECT *, code as array_key
14-
FROM currency as currency WHERE 1 = 1
14+
FROM currency WHERE 1 = 1
1515

1616
@IF isset(:status) AND :status != ""
1717
THEN

admin/sql/mysqli/digital_asset.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
, o.customer_order_id, o.order_id, op.name as product_name
2222
END @IF
2323

24-
FROM digital_asset AS digital_asset
24+
FROM digital_asset
2525
INNER JOIN digital_asset_content ON digital_asset_content.digital_asset_id = digital_asset.digital_asset_id
2626
AND digital_asset_content.language_id = :language_id
2727

admin/sql/mysqli/digital_asset_log.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
SELECT digital_asset_log.*
1515

16-
FROM digital_asset_log AS digital_asset_log
16+
FROM digital_asset_log
1717

1818
WHERE 1 = 1
1919

admin/sql/mysqli/field.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
BEGIN
1919
-- field_item
2020
SELECT *, field_id as array_key
21-
FROM field as field
21+
FROM field
2222
-- LEFT JOIN field_to_site t2s ON (field_item.field_item_id = t2s.field_item_id)
2323

2424
WHERE 1 = 1

admin/sql/mysqli/field_group.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
BEGIN
1313
-- field_group
1414
SELECT *
15-
FROM field_group AS field_group
15+
FROM field_group
1616
INNER JOIN field_group_content ON field_group_content.field_group_id = field_group.field_group_id
1717
WHERE 1 = 1
1818

admin/sql/mysqli/language.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
BEGIN
1414
-- language
1515
SELECT *, code as array_key
16-
FROM language as language WHERE 1 = 1
16+
FROM language WHERE 1 = 1
1717

1818
@IF isset(:status)
1919
THEN

admin/sql/mysqli/length_type.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
BEGIN
1313
-- length_type
1414
SELECT *, length_type.length_type_id as array_key
15-
FROM length_type AS length_type
15+
FROM length_type
1616
INNER JOIN length_type_content ON length_type_content.length_type_id = length_type.length_type_id
1717
WHERE 1 = 1
1818

admin/sql/mysqli/manufacturer.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
)
110110
BEGIN
111111

112-
SELECT * FROM manufacturer AS manufacturer
112+
SELECT * FROM manufacturer
113113

114114
LEFT JOIN manufacturer_to_site p2s ON (manufacturer.manufacturer_id = p2s.manufacturer_id)
115115
WHERE p2s.site_id = :site_id

admin/sql/mysqli/media_content.sql

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@
1212
)
1313
BEGIN
1414
-- media_content
15-
SELECT media.*,media_content.*
15+
SELECT media_content.*,media_content.*
1616

1717
@IF !empty(:content)
1818
THEN
1919
,content
2020
END @IF
2121

22-
FROM media_content AS media
22+
FROM media_content
2323
WHERE 1 = 1
2424

2525
@IF !empty(:media_id)
2626
THEN
27-
AND media.media_id = :media_id
27+
AND media_content.media_id = :media_id
2828
END @IF
2929

3030
@IF !empty(:language_id)
3131
THEN
32-
AND media.language_id = :language_id
32+
AND media_content.language_id = :language_id
3333
END @IF
3434

3535
@IF !empty(:limit)
@@ -40,7 +40,7 @@
4040

4141
SELECT count(*) FROM (
4242

43-
@SQL_COUNT(media.media_id, media_content) -- this takes previous query removes limit and replaces select columns with parameter product_id
43+
@SQL_COUNT(media_content.media_id, media_content) -- this takes previous query removes limit and replaces select columns with parameter product_id
4444

4545
) as count;
4646

admin/sql/mysqli/menu.sql

+12-12
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
-- get all menus
9292

93-
CREATE PROCEDURE getMenusList(
93+
CREATE PROCEDURE getAll(
9494

9595
-- variables
9696
IN language_id INT,
@@ -113,7 +113,7 @@
113113

114114
SELECT *, menu.menu_id as array_key
115115

116-
FROM menu AS menu
116+
FROM menu
117117

118118

119119
@SQL_LIMIT(:start, :limit);
@@ -125,12 +125,12 @@
125125
) as count;
126126

127127

128-
END -- get all menus
128+
END
129129

130130

131-
-- get all menus
131+
-- get menu
132132

133-
CREATE PROCEDURE getMenus(
133+
CREATE PROCEDURE get(
134134

135135
-- variables
136136
IN language_id INT,
@@ -150,13 +150,13 @@
150150
)
151151
BEGIN
152152

153-
SELECT td.*,menus.url, menus.sort_order, menus.parent_id, menus.type, menus.item_id, menus.menu_item_id as array_key
153+
SELECT td.*,menu.url, menu.sort_order, menu.parent_id, menu.type, menu.item_id, menu.menu_item_id as array_key
154154

155155

156-
FROM menu_item AS menus
156+
FROM menu_item AS menu
157157

158-
-- INNER JOIN menu_to_site c2s ON (menus.menu_id = c2s.menu_id AND c2s.site_id = :site_id)
159-
INNER JOIN menu_item_content td ON (menus.menu_item_id = td.menu_item_id AND td.language_id = :language_id)
158+
-- INNER JOIN menu_to_site c2s ON (menu.menu_id = c2s.menu_id AND c2s.site_id = :site_id)
159+
INNER JOIN menu_item_content td ON (menu.menu_item_id = td.menu_item_id AND td.language_id = :language_id)
160160

161161
WHERE
162162

@@ -166,18 +166,18 @@
166166
@IF isset(:menu_id)
167167
THEN
168168

169-
AND menus.menu_id = :menu_id
169+
AND menu.menu_id = :menu_id
170170

171171
END @IF
172172

173173
@IF isset(:slug)
174174
THEN
175175

176-
AND menus.menu_id = (SELECT menu_id FROM menu WHERE slug = :slug LIMIT 1)
176+
AND menu.menu_id = (SELECT menu_id FROM menu WHERE slug = :slug LIMIT 1)
177177

178178
END @IF
179179

180-
ORDER BY menus.parent_id, menus.sort_order, menus.menu_id
180+
ORDER BY menu.parent_id, menu.sort_order, menu.menu_id
181181

182182
@IF isset(:limit)
183183
THEN

admin/sql/mysqli/option.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
BEGIN
1313
-- option
1414
SELECT `option`.*, option_content.name
15-
FROM `option` AS `option`
15+
FROM `option`
1616
INNER JOIN option_content
1717
ON option_content.option_id = `option`.option_id AND option_content.language_id = :language_id
1818

admin/sql/mysqli/option_value.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
BEGIN
1414
-- option_value
1515
SELECT option_value.*, option_value_content.name
16-
FROM option_value AS option_value
16+
FROM option_value
1717
INNER JOIN option_value_content
1818
ON option_value_content.option_value_id = option_value.option_value_id AND option_value_content.language_id = :language_id
1919

admin/sql/mysqli/order.sql

+10-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
-- pagination
2525
IN start INT,
2626
IN limit INT,
27+
IN order_by CHAR,
28+
IN direction CHAR,
2729

2830

2931
-- return
@@ -94,8 +96,14 @@
9496
`order`.first_name LIKE CONCAT('%',:search,'%') OR
9597
`order`.last_name LIKE CONCAT('%',:search,'%')
9698
END @IF
97-
98-
ORDER BY order_id DESC
99+
100+
-- ORDER BY parameters can't be binded, because they are added to the query directly they must be properly sanitized by only allowing a predefined set of values
101+
@IF isset(:order_by)
102+
THEN
103+
ORDER BY $order_by $direction
104+
@ELSE
105+
ORDER BY order_id DESC
106+
END @IF
99107

100108
@SQL_LIMIT(:start, :limit);
101109

admin/sql/mysqli/order_log.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
BEGIN
1313
-- order_log
1414
SELECT *
15-
FROM order_log AS order_log WHERE 1 = 1
15+
FROM order_log WHERE 1 = 1
1616

1717
@IF !empty(:order_id)
1818
THEN

admin/sql/mysqli/order_status.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
)
1212
BEGIN
1313
SELECT *
14-
FROM order_status AS order_status WHERE 1 = 1
14+
FROM order_status WHERE 1 = 1
1515

1616
@IF !empty(:language_id)
1717
THEN

admin/sql/mysqli/payment_status.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
BEGIN
1313

1414
SELECT *
15-
FROM payment_status AS payment_status WHERE 1 = 1
15+
FROM payment_status WHERE 1 = 1
1616

1717
@IF !empty(:language_id)
1818
THEN

0 commit comments

Comments
 (0)