Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Added new deleteMenuItemRecursive with CTE for recursive delete and kept deleteMenuItem without CTE for older mysql version that don't support it, fixed setMulti query for settings, removed redundant ; from @FILTER

givanzb11179aacd51
diff --git a/admin/sql/mysqli/admin.sql b/admin/sql/mysqli/admin.sql
index 6e2ec8f..26ceee9 100755
--- a/admin/sql/mysqli/admin.sql
+++ b/admin/sql/mysqli/admin.sql
@@ -121,7 +121,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:admin, admin);
+ @FILTER(:admin, admin)
INSERT INTO admin
@@ -143,7 +143,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:admin, admin);
+ @FILTER(:admin, admin)
UPDATE admin
diff --git a/admin/sql/mysqli/attribute.sql b/admin/sql/mysqli/attribute.sql
index 5cd1b93..e1b3730 100755
--- a/admin/sql/mysqli/attribute.sql
+++ b/admin/sql/mysqli/attribute.sql
@@ -88,7 +88,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :attribute_data = @FILTER(:attribute, attribute);
+ :attribute_data = @FILTER(:attribute, attribute)
INSERT INTO attribute
@@ -98,7 +98,7 @@
VALUES ( :attribute_data );
- :attribute_content = @FILTER(:attribute, attribute_content);
+ :attribute_content = @FILTER(:attribute, attribute_content)
INSERT INTO attribute_content
@@ -119,7 +119,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :attribute_data = @FILTER(:attribute, attribute);
+ :attribute_data = @FILTER(:attribute, attribute)
UPDATE attribute
@@ -128,7 +128,7 @@
WHERE attribute_id = :attribute_id;
-- allow only table fields and set defaults for missing values
- :attribute_content = @FILTER(:attribute, attribute_content);
+ :attribute_content = @FILTER(:attribute, attribute_content)
UPDATE attribute_content
diff --git a/admin/sql/mysqli/attribute_group.sql b/admin/sql/mysqli/attribute_group.sql
index 40da1b4..f42cb70 100755
--- a/admin/sql/mysqli/attribute_group.sql
+++ b/admin/sql/mysqli/attribute_group.sql
@@ -74,7 +74,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :attribute_group_data = @FILTER(:attribute_group, attribute_group);
+ :attribute_group_data = @FILTER(:attribute_group, attribute_group)
INSERT INTO attribute_group
@@ -84,7 +84,7 @@
VALUES ( :attribute_group_data );
- :attribute_group_content = @FILTER(:attribute_group, attribute_group_content);
+ :attribute_group_content = @FILTER(:attribute_group, attribute_group_content)
INSERT INTO attribute_group_content
@@ -105,7 +105,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :attribute_group_data = @FILTER(:attribute_group, attribute_group);
+ :attribute_group_data = @FILTER(:attribute_group, attribute_group)
UPDATE attribute_group
@@ -114,7 +114,7 @@
WHERE attribute_group_id = :attribute_group_id;
-- allow only table fields and set defaults for missing values
- :attribute_group_content = @FILTER(:attribute_group, attribute_group_content);
+ :attribute_group_content = @FILTER(:attribute_group, attribute_group_content)
UPDATE attribute_group_content
diff --git a/admin/sql/mysqli/category.sql b/admin/sql/mysqli/category.sql
index 39a624b..b399f07 100644
--- a/admin/sql/mysqli/category.sql
+++ b/admin/sql/mysqli/category.sql
@@ -20,7 +20,7 @@
-- return array of categories for categories query
OUT fetch_all,
-- return categories count for count query
- OUT fetch_one,
+ OUT fetch_one
)
BEGIN
@@ -153,10 +153,10 @@
-- return array of categories for categories query
OUT fetch_all,
-- return categories count for count query
- OUT fetch_one,
+ OUT fetch_one
)
BEGIN
- SET group_concat_max_len = 10000;
+ -- SET group_concat_max_len = 10000;
SELECT DISTINCT categories.taxonomy_item_id, @taxonomy_item_id := categories.taxonomy_item_id, categories.*, tc.*, tc.content as content, categories.taxonomy_item_id as array_key
@@ -248,7 +248,7 @@
IN post_type CHAR,
IN type CHAR,
IN slug CHAR,
- OUT fetch_row,
+ OUT fetch_row
)
BEGIN
-- taxonomy_item
@@ -332,7 +332,7 @@
IN language_id INT,
IN post_type CHAR,
IN slug CHAR,
- OUT fetch_row,
+ OUT fetch_row
)
BEGIN
@@ -410,7 +410,7 @@
DELETE FROM taxonomy_item_content WHERE taxonomy_item_id = :taxonomy_item_id;
- @FILTER(:taxonomy_item_content, taxonomy_item_content);
+ @FILTER(:taxonomy_item_content, taxonomy_item_content)
@EACH(:taxonomy_item_content)
INSERT INTO taxonomy_item_content
@@ -423,7 +423,7 @@
-- SELECT * FROM taxonomy_item_option WHERE taxonomy_item_id = :taxonomy_item_id;
-- allow only table fields and set defaults for missing values
- @FILTER(:taxonomy_item, taxonomy_item);
+ @FILTER(:taxonomy_item, taxonomy_item)
UPDATE taxonomy_item
@@ -442,13 +442,13 @@
IN site_id INT,
OUT insert_id,
OUT insert_id,
- OUT insert_id,
+ OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :taxonomy_item = @FILTER(:taxonomy_item, taxonomy_item);
- :taxonomy_item_content = @FILTER(:taxonomy_item_content, taxonomy_item_content);
+ :taxonomy_item = @FILTER(:taxonomy_item, taxonomy_item)
+ :taxonomy_item_content = @FILTER(:taxonomy_item_content, taxonomy_item_content)
INSERT INTO taxonomy_item
@@ -457,13 +457,6 @@
VALUES ( :taxonomy_item );
- -- SET :taxonomy_item_content.taxonomy_item_id = last_insert_id;
- -- SET @taxonomy_item_id = LAST_INSERT_ID();
-
- -- UPDATE taxonomy_item SET image = :image WHERE taxonomy_item_id = :taxonomy_item_id;
-
- -- :taxonomy_item = @FILTER(:taxonomy_item, taxonomy_item);
-
INSERT INTO taxonomy_item_content
( taxonomy_item_id, @KEYS(:taxonomy_item_content) )
@@ -477,8 +470,6 @@
VALUES ( @result.taxonomy_item, :site_id );
-
- SELECT @taxonomy_item_id as taxonomy_item_id;
END
@@ -499,7 +490,7 @@
-- return array of categories for categories query
OUT fetch_all,
-- return categories count for count query
- OUT fetch_one,
+ OUT fetch_one
)
BEGIN
@@ -591,7 +582,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :taxonomy_item_content_data = @FILTER(:taxonomy_item.taxonomy_item_content, taxonomy_item_content);
+ :taxonomy_item_content_data = @FILTER(:taxonomy_item.taxonomy_item_content, taxonomy_item_content)
@EACH(:taxonomy_item_content_data)
INSERT INTO taxonomy_item_content
@@ -602,7 +593,7 @@
ON DUPLICATE KEY UPDATE @LIST(:each);
-- allow only table fields and set defaults for missing values
- @FILTER(:taxonomy_item, taxonomy_item);
+ @FILTER(:taxonomy_item, taxonomy_item)
UPDATE taxonomy_item
@@ -618,13 +609,14 @@
CREATE PROCEDURE addTaxonomyItem(
IN taxonomy_item ARRAY,
IN site_id INT,
+ OUT insert_id,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :taxonomy_item_content_data = @FILTER(:taxonomy_item.taxonomy_item_content, taxonomy_item_content);
- :taxonomy_item_data = @FILTER(:taxonomy_item, taxonomy_item);
+ :taxonomy_item_content_data = @FILTER(:taxonomy_item.taxonomy_item_content, taxonomy_item_content)
+ :taxonomy_item_data = @FILTER(:taxonomy_item, taxonomy_item)
INSERT INTO taxonomy_item
@@ -646,8 +638,6 @@
VALUES ( @result.taxonomy_item, :each );
-
- SELECT @taxonomy_item as taxonomy_item;
END
@@ -659,7 +649,7 @@
)
BEGIN
- :taxonomy_item_data = @FILTER(:taxonomy_items, taxonomy_item);
+ :taxonomy_item_data = @FILTER(:taxonomy_items, taxonomy_item)
@EACH(:taxonomy_item_data)
UPDATE taxonomy_item
diff --git a/admin/sql/mysqli/comment.sql b/admin/sql/mysqli/comment.sql
index 8fa5ad0..ece5e40 100755
--- a/admin/sql/mysqli/comment.sql
+++ b/admin/sql/mysqli/comment.sql
@@ -115,7 +115,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:comment, comment);
+ @FILTER(:comment, comment)
INSERT INTO comment
@@ -134,7 +134,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:comment, comment);
+ @FILTER(:comment, comment)
UPDATE comment
diff --git a/admin/sql/mysqli/country.sql b/admin/sql/mysqli/country.sql
index 74f72f7..164cae1 100755
--- a/admin/sql/mysqli/country.sql
+++ b/admin/sql/mysqli/country.sql
@@ -64,7 +64,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :country_data = @FILTER(:country, country);
+ :country_data = @FILTER(:country, country)
INSERT INTO country
@@ -85,7 +85,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:country, country);
+ @FILTER(:country, country)
UPDATE country
diff --git a/admin/sql/mysqli/coupon.sql b/admin/sql/mysqli/coupon.sql
index a68831d..dc889af 100755
--- a/admin/sql/mysqli/coupon.sql
+++ b/admin/sql/mysqli/coupon.sql
@@ -72,7 +72,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :coupon_data = @FILTER(:coupon, coupon);
+ :coupon_data = @FILTER(:coupon, coupon)
INSERT INTO coupon
@@ -93,7 +93,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:coupon, coupon);
+ @FILTER(:coupon, coupon)
UPDATE coupon
diff --git a/admin/sql/mysqli/currency.sql b/admin/sql/mysqli/currency.sql
index 536f6dd..8369310 100755
--- a/admin/sql/mysqli/currency.sql
+++ b/admin/sql/mysqli/currency.sql
@@ -48,7 +48,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :currency_data = @FILTER(:currency, currency);
+ :currency_data = @FILTER(:currency, currency)
INSERT INTO currency
@@ -68,7 +68,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:currency, currency);
+ @FILTER(:currency, currency)
UPDATE currency
diff --git a/admin/sql/mysqli/digital_asset.sql b/admin/sql/mysqli/digital_asset.sql
index 81a774c..6b0b0d0 100755
--- a/admin/sql/mysqli/digital_asset.sql
+++ b/admin/sql/mysqli/digital_asset.sql
@@ -58,7 +58,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :digital_asset_data = @FILTER(:digital_asset, digital_asset);
+ :digital_asset_data = @FILTER(:digital_asset, digital_asset)
INSERT INTO digital_asset
@@ -68,7 +68,7 @@
VALUES ( :digital_asset_data );
- :digital_asset_content = @FILTER(:digital_asset, digital_asset_content);
+ :digital_asset_content = @FILTER(:digital_asset, digital_asset_content)
INSERT INTO digital_asset_content
@@ -89,7 +89,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :digital_asset_data = @FILTER(:digital_asset, digital_asset);
+ :digital_asset_data = @FILTER(:digital_asset, digital_asset)
UPDATE digital_asset
@@ -98,7 +98,7 @@
WHERE digital_asset_id = :digital_asset_id;
-- allow only table fields and set defaults for missing values
- :digital_asset_content = @FILTER(:digital_asset, digital_asset_content);
+ :digital_asset_content = @FILTER(:digital_asset, digital_asset_content)
UPDATE digital_asset_content
diff --git a/admin/sql/mysqli/field_group.sql b/admin/sql/mysqli/field_group.sql
index 88290d8..8a18f95 100755
--- a/admin/sql/mysqli/field_group.sql
+++ b/admin/sql/mysqli/field_group.sql
@@ -58,14 +58,14 @@
PROCEDURE add(
IN field_group ARRAY,
IN language_id INT,
- OUT insert_id
- OUT affected_rows
+ OUT insert_id,
+ OUT affected_rows,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :field_group_data = @FILTER(:field_group, field_group);
+ :field_group_data = @FILTER(:field_group, field_group)
INSERT INTO field_group
@@ -74,7 +74,7 @@
VALUES ( :field_group_data);
-- allow only table fields and set defaults for missing values
- :field_group_content_data = @FILTER(:field_group, field_group_content);
+ :field_group_content_data = @FILTER(:field_group, field_group_content)
INSERT INTO field_group_content
@@ -94,7 +94,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :field_group_data = @FILTER(:field_group, field_group);
+ :field_group_data = @FILTER(:field_group, field_group)
UPDATE field_group
@@ -103,7 +103,7 @@
WHERE field_group_id = :field_group_id;
-- allow only table fields and set defaults for missing values
- :field_group_content_data = @FILTER(:field_group, field_group_content);
+ :field_group_content_data = @FILTER(:field_group, field_group_content)
UPDATE field_group_content
diff --git a/admin/sql/mysqli/language.sql b/admin/sql/mysqli/language.sql
index c6e07a2..d76e436 100755
--- a/admin/sql/mysqli/language.sql
+++ b/admin/sql/mysqli/language.sql
@@ -70,7 +70,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :language_data = @FILTER(:language, language);
+ :language_data = @FILTER(:language, language)
INSERT INTO language
@@ -103,7 +103,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:language, language);
+ @FILTER(:language, language)
UPDATE language
diff --git a/admin/sql/mysqli/length_type.sql b/admin/sql/mysqli/length_type.sql
index 56e44d2..a3558b8 100755
--- a/admin/sql/mysqli/length_type.sql
+++ b/admin/sql/mysqli/length_type.sql
@@ -65,7 +65,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :length_type_data = @FILTER(:length_type, length_type);
+ :length_type_data = @FILTER(:length_type, length_type)
INSERT INTO length_type
@@ -74,7 +74,7 @@
VALUES ( :length_type_data);
-- allow only table fields and set defaults for missing values
- :length_type_content_data = @FILTER(:length_type, length_type_content);
+ :length_type_content_data = @FILTER(:length_type, length_type_content)
INSERT INTO length_type_content
@@ -94,7 +94,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :length_type_data = @FILTER(:length_type, length_type);
+ :length_type_data = @FILTER(:length_type, length_type)
UPDATE length_type
@@ -103,7 +103,7 @@
WHERE length_type_id = :length_type_id;
-- allow only table fields and set defaults for missing values
- :length_type_content_data = @FILTER(:length_type, length_type_content);
+ :length_type_content_data = @FILTER(:length_type, length_type_content)
UPDATE length_type_content
diff --git a/admin/sql/mysqli/manufacturer.sql b/admin/sql/mysqli/manufacturer.sql
index 663e8c9..e512196 100755
--- a/admin/sql/mysqli/manufacturer.sql
+++ b/admin/sql/mysqli/manufacturer.sql
@@ -50,7 +50,7 @@
-- SELECT * FROM manufacturer_option WHERE manufacturer_id = :manufacturer_id;
-- allow only table fields and set defaults for missing values
- @FILTER(:manufacturer, manufacturer);
+ @FILTER(:manufacturer, manufacturer)
UPDATE manufacturer
@@ -70,7 +70,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :manufacturer = @FILTER(:manufacturer, manufacturer);
+ :manufacturer = @FILTER(:manufacturer, manufacturer)
INSERT INTO manufacturer
diff --git a/admin/sql/mysqli/menu.sql b/admin/sql/mysqli/menu.sql
index 6deecc4..ee44c36 100644
--- a/admin/sql/mysqli/menu.sql
+++ b/admin/sql/mysqli/menu.sql
@@ -10,7 +10,7 @@
IN site_id INT,
-- return menus count for count query
- OUT fetch_row,
+ OUT fetch_row
)
BEGIN
@@ -34,7 +34,7 @@
IN name CHAR,
-- return menus count for count query
- OUT affected_rows,
+ OUT affected_rows
)
BEGIN
@@ -53,10 +53,10 @@
IN menu ARRAY,
-- return menus count for count query
- OUT insert_id,
+ OUT insert_id
)
BEGIN
- @FILTER(:menu, menu);
+ @FILTER(:menu, menu)
INSERT INTO menu
@@ -146,7 +146,7 @@
-- return array of menus for menus query
OUT fetch_all,
-- return menus count for count query
- -- OUT fetch_one,
+ -- OUT fetch_one
)
BEGIN
@@ -275,7 +275,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :menu_item_content_data = @FILTER(:menu_item.menu_item_content, menu_item_content);
+ :menu_item_content_data = @FILTER(:menu_item.menu_item_content, menu_item_content)
@EACH(:menu_item_content_data)
INSERT INTO menu_item_content
@@ -286,7 +286,7 @@
ON DUPLICATE KEY UPDATE @LIST(:each);
-- allow only table fields and set defaults for missing values
- @FILTER(:menu_item, menu_item);
+ @FILTER(:menu_item, menu_item)
UPDATE menu_item
@@ -301,13 +301,14 @@
CREATE PROCEDURE addMenuItem(
IN menu_item ARRAY,
+ OUT insert_id,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :menu_item_content_data = @FILTER(:menu_item.menu_item_content, menu_item_content);
- :menu_item_data = @FILTER(:menu_item, menu_item);
+ :menu_item_content_data = @FILTER(:menu_item.menu_item_content, menu_item_content)
+ :menu_item_data = @FILTER(:menu_item, menu_item)
INSERT INTO menu_item
@@ -323,8 +324,6 @@
VALUES ( @result.menu_item, :each );
-
- SELECT @menu_item as menu_item;
END
-- Reorder menu items
@@ -335,7 +334,7 @@
)
BEGIN
- :menu_item_data = @FILTER(:menu_items, menu_item);
+ :menu_item_data = @FILTER(:menu_items, menu_item)
@EACH(:menu_item_data)
UPDATE menu_item
@@ -346,9 +345,9 @@
END
- -- Delete menu item
+ -- Delete menu item recursive
- CREATE PROCEDURE deleteMenuItem(
+ CREATE PROCEDURE deleteMenuItemRecursive(
IN menu_item_id INT,
OUT affected_rows,
OUT affected_rows,
@@ -390,3 +389,21 @@
SELECT menu_item_id FROM tree);
END
+
+ -- Delete menu item
+
+ CREATE PROCEDURE deleteMenuItem(
+ IN menu_item_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- non CTE for older mysql versions, does not delete grand child menu items
+ DELETE FROM menu_item_content WHERE menu_item_id IN (SELECT menu_item_id FROM menu_item WHERE parent_id = :menu_item_id);
+ DELETE FROM menu_item_content WHERE menu_item_id = :menu_item_id;
+
+ DELETE FROM menu_item WHERE menu_item_id IN (SELECT menu_item_id FROM (SELECT menu_item_id FROM menu_item) as mi WHERE parent_id = :menu_item_id);
+ DELETE FROM menu_item WHERE menu_item_id = :menu_item_id;
+
+ END
diff --git a/admin/sql/mysqli/option.sql b/admin/sql/mysqli/option.sql
index 40ef7f7..98e579b 100644
--- a/admin/sql/mysqli/option.sql
+++ b/admin/sql/mysqli/option.sql
@@ -58,7 +58,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :option_data = @FILTER(:option, option);
+ :option_data = @FILTER(:option, option)
INSERT INTO `option`
@@ -68,7 +68,7 @@
VALUES ( :option_data );
- :option_content = @FILTER(:option, option_content);
+ :option_content = @FILTER(:option, option_content)
INSERT INTO option_content
@@ -89,7 +89,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :option_data = @FILTER(:option, option);
+ :option_data = @FILTER(:option, option)
UPDATE `option`
@@ -98,7 +98,7 @@
WHERE option_id = :option_id;
-- allow only table fields and set defaults for missing values
- :option_content = @FILTER(:option, option_content);
+ :option_content = @FILTER(:option, option_content)
UPDATE option_content
diff --git a/admin/sql/mysqli/option_value.sql b/admin/sql/mysqli/option_value.sql
index 38c3f89..f34eb7e 100644
--- a/admin/sql/mysqli/option_value.sql
+++ b/admin/sql/mysqli/option_value.sql
@@ -65,7 +65,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :option_value_data = @FILTER(:option_value, option_value);
+ :option_value_data = @FILTER(:option_value, option_value)
INSERT INTO option_value
@@ -75,7 +75,7 @@
VALUES ( :option_value_data );
- :option_value_content = @FILTER(:option_value, option_value_content);
+ :option_value_content = @FILTER(:option_value, option_value_content)
INSERT INTO option_value_content
@@ -96,7 +96,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :option_value_data = @FILTER(:option_value, option_value);
+ :option_value_data = @FILTER(:option_value, option_value)
UPDATE option_value
@@ -105,7 +105,7 @@
WHERE option_value_id = :option_value_id;
-- allow only table fields and set defaults for missing values
- :option_value_content = @FILTER(:option_value, option_value_content);
+ :option_value_content = @FILTER(:option_value, option_value_content)
UPDATE option_value_content
diff --git a/admin/sql/mysqli/order.sql b/admin/sql/mysqli/order.sql
index 15d939a..eaa9f6f 100755
--- a/admin/sql/mysqli/order.sql
+++ b/admin/sql/mysqli/order.sql
@@ -267,9 +267,10 @@
)
BEGIN
- :products = @FILTER(:order.products, order_product, false, true);
- :totals = @FILTER(:order.totals, order_total, false, true);
- @FILTER(:order, order);
+ :products = @FILTER(:order.products, order_product, false, true)
+ :totals = @FILTER(:order.totals, order_total, false, true)
+
+ @FILTER(:order, order)
INSERT INTO `order`
@@ -287,7 +288,7 @@
@EACH(:product_options)
INSERT INTO order_product_option
( order_id, @KEYS(:each) )
- VALUES ( @result.order, 0, :each );
+ VALUES ( @result.order, :each );
-- insert order products
@EACH(:totals)
@@ -306,7 +307,7 @@
)
BEGIN
- @FILTER(:order, order);
+ @FILTER(:order, order)
UPDATE `order`
@@ -325,8 +326,8 @@
)
BEGIN
- :products = @FILTER(:products, order_product, false, true);
- :product_options = @FILTER(:product_options, order_product_option, false, true);
+ :products = @FILTER(:products, order_product, false, true)
+ :product_options = @FILTER(:product_options, order_product_option, false, true)
-- insert products
@EACH(:products)
diff --git a/admin/sql/mysqli/order_log.sql b/admin/sql/mysqli/order_log.sql
index 3c0d0c1..6814bd9 100644
--- a/admin/sql/mysqli/order_log.sql
+++ b/admin/sql/mysqli/order_log.sql
@@ -51,7 +51,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :order_log_data = @FILTER(:order_log, order_log);
+ :order_log_data = @FILTER(:order_log, order_log)
INSERT INTO order_log
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:order_log, order_log);
+ @FILTER(:order_log, order_log)
UPDATE order_log
diff --git a/admin/sql/mysqli/order_status.sql b/admin/sql/mysqli/order_status.sql
index 1c40897..ffa3dc9 100755
--- a/admin/sql/mysqli/order_status.sql
+++ b/admin/sql/mysqli/order_status.sql
@@ -51,7 +51,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :order_status_data = @FILTER(:order_status, order_status);
+ :order_status_data = @FILTER(:order_status, order_status)
INSERT INTO order_status
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:order_status, order_status);
+ @FILTER(:order_status, order_status)
UPDATE order_status
diff --git a/admin/sql/mysqli/post.sql b/admin/sql/mysqli/post.sql
index 3bca494..9f3b8d4 100755
--- a/admin/sql/mysqli/post.sql
+++ b/admin/sql/mysqli/post.sql
@@ -335,13 +335,16 @@
CREATE PROCEDURE add(
IN post ARRAY,
- IN site_id INT,
+ IN site_id ARRAY,
+ OUT insert_id
+ OUT insert_id
+ OUT insert_id
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :post_data = @FILTER(:post, post);
+ :post_data = @FILTER(:post, post)
INSERT INTO post
@@ -350,7 +353,7 @@
VALUES ( :post_data );
- :post.post_content = @FILTER(:post.post_content, post_content, false, true);
+ :post.post_content = @FILTER(:post.post_content, post_content, false, true)
@EACH(:post.post_content)
@@ -368,11 +371,12 @@
VALUES ( :each, @result.post)
ON DUPLICATE KEY UPDATE taxonomy_item_id = :each;
- INSERT INTO post_to_site
-
- ( post_id, site_id )
+ @EACH(:site_id)
+ INSERT INTO post_to_site
- VALUES ( @result.post, :site_id );
+ ( post_id, site_id )
+
+ VALUES ( @result.post, :each );
END
@@ -381,12 +385,12 @@
CREATE PROCEDURE edit(
IN post ARRAY,
IN post_id INT,
- IN site_id INT,
+ IN site_id ARRAY,
OUT affected_rows
)
BEGIN
- :post.post_content = @FILTER(:post.post_content, post_content, false, true);
+ :post.post_content = @FILTER(:post.post_content, post_content, false, true)
@EACH(:post.post_content)
INSERT INTO post_content
@@ -397,29 +401,34 @@
ON DUPLICATE KEY UPDATE @LIST(:each);
- -- @IF isset(:post.taxonomy_item)
-
- DELETE FROM post_to_taxonomy_item WHERE post_id = :post_id;
+ @IF isset(:post.taxonomy_item)
+ THEN
+ DELETE FROM post_to_taxonomy_item WHERE post_id = :post_id
+ END @IF;
- @EACH(:post.taxonomy_item)
- INSERT INTO post_to_taxonomy_item
+ @EACH(:post.taxonomy_item)
+ INSERT INTO post_to_taxonomy_item
+
+ ( taxonomy_item_id, post_id)
- ( taxonomy_item_id, post_id)
-
- VALUES ( :each, :post_id)
- ON DUPLICATE KEY UPDATE taxonomy_item_id = :each;
+ VALUES ( :each, :post_id)
+ ON DUPLICATE KEY UPDATE taxonomy_item_id = :each;
- -- END @IF
+ @IF isset(:site_id)
+ THEN
+ DELETE FROM post_to_site WHERE post_id = :post_id
+ END @IF;
- INSERT IGNORE INTO post_to_site
-
- ( post_id, site_id )
+ @EACH(:site_id)
+ INSERT INTO post_to_site
- VALUES ( :post_id, :site_id );
+ ( post_id, site_id )
+
+ VALUES ( :post_id, :each );
-- allow only table fields and set defaults for missing values
- @FILTER(:post, post);
+ @FILTER(:post, post)
@IF !empty(:post)
THEN
@@ -428,7 +437,7 @@
SET @LIST(:post)
WHERE post_id = :post_id
- END @IF
+ END @IF;
@@ -444,7 +453,7 @@
)
BEGIN
- :post_content = @FILTER(:post_content, post_content);
+ :post_content = @FILTER(:post_content, post_content)
UPDATE post_content
@@ -459,9 +468,9 @@
CREATE PROCEDURE delete(
IN post_id ARRAY,
IN site_id INT,
- OUT affected_rows
- OUT affected_rows
- OUT affected_rows
+ OUT affected_rows,
+ OUT affected_rows,
+ OUT affected_rows,
OUT affected_rows
)
BEGIN
diff --git a/admin/sql/mysqli/post_content_revision.sql b/admin/sql/mysqli/post_content_revision.sql
index a8f8341..77df20b 100644
--- a/admin/sql/mysqli/post_content_revision.sql
+++ b/admin/sql/mysqli/post_content_revision.sql
@@ -100,7 +100,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :post_content_revision_data = @FILTER(:revision, post_content_revision);
+ :post_content_revision_data = @FILTER(:revision, post_content_revision)
INSERT INTO post_content_revision
@@ -122,7 +122,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:revision, post_content_revision);
+ @FILTER(:revision, post_content_revision)
UPDATE post_content_revision
diff --git a/admin/sql/mysqli/product.sql b/admin/sql/mysqli/product.sql
index 42f7219..7e7aea9 100755
--- a/admin/sql/mysqli/product.sql
+++ b/admin/sql/mysqli/product.sql
@@ -399,13 +399,14 @@
PROCEDURE edit(
IN product ARRAY,
IN product_id INT,
- OUT insert_id
- OUT affected_rows
- OUT affected_rows
+ IN site_id ARRAY,
+ OUT insert_id,
+ OUT affected_rows,
+ OUT affected_rows,
OUT insert_id
)
BEGIN
- :product.product_content = @FILTER(:product.product_content, product_content, false);
+ :product.product_content = @FILTER(:product.product_content, product_content, false)
@EACH(:product.product_content)
INSERT INTO product_content
@@ -417,7 +418,10 @@
ON DUPLICATE KEY UPDATE @LIST(:each);
- DELETE FROM product_to_taxonomy_item WHERE product_id = :product_id;
+ @IF isset(:product.taxonomy_item)
+ THEN
+ DELETE FROM product_to_taxonomy_item WHERE product_id = :product_id
+ END @IF;
@EACH(:product.taxonomy_item)
INSERT INTO product_to_taxonomy_item
@@ -427,13 +431,26 @@
VALUES ( :each, :product_id)
ON DUPLICATE KEY UPDATE taxonomy_item_id = :each;
- -- SELECT * FROM product_option WHERE product_id = :product_id;
+
+ @IF isset(:site_id)
+ THEN
+ DELETE FROM product_to_site WHERE product_id = :product_id
+ END @IF;
+
+ @EACH(:site_id)
+ INSERT INTO product_to_site
+
+ ( product_id, site_id )
+
+ VALUES ( :product_id, :each );
+
+ -- SELECT * FROM product_option WHERE product_id = :product_id;
-- SELECT * FROM product_option WHERE product_id = :product_id;
-- allow only table fields and set defaults for missing values
- :product_update = @FILTER(:product, product, false);
+ :product_update = @FILTER(:product, product, false)
UPDATE product
@@ -455,7 +472,7 @@
)
BEGIN
- :product_content = @FILTER(:product_content, product_content);
+ :product_content = @FILTER(:product_content, product_content)
UPDATE product_content
@@ -469,15 +486,16 @@
CREATE PROCEDURE add(
IN product ARRAY,
+ IN site_id ARRAY,
+ OUT insert_id,
+ OUT insert_id,
OUT insert_id,
- OUT insert_id
- OUT insert_id
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :product_data = @FILTER(:product, product);
+ :product_data = @FILTER(:product, product)
INSERT INTO product
@@ -502,17 +520,14 @@
VALUES ( :each, @result.product_data)
ON DUPLICATE KEY UPDATE taxonomy_item_id = :each;
+
+ @EACH(:site_id)
+ INSERT INTO product_to_site
- -- UPDATE product SET image = :image WHERE product_id = :product_id;
-
- -- :product = @FILTER(:product_data, product);
-
- INSERT INTO product_to_site
-
- ( product_id, site_id )
-
- VALUES ( @result.product, :site_id );
-
+ ( product_id, site_id )
+
+ VALUES ( @result.product, :each );
+
END
-- Edit product
@@ -766,7 +781,7 @@
@IF !empty(:product_image)
THEN
- --,(SELECT CONCAT('[', GROUP_CONCAT('{"id":"', pi.product_image_id, '","image":"', pi.image, '"}'), ']')
+ -- ,(SELECT CONCAT('[', GROUP_CONCAT('{"id":"', pi.product_image_id, '","image":"', pi.image, '"}'), ']')
,(SELECT JSON_ARRAYAGG( JSON_OBJECT('id', pi.product_image_id, 'image', pi.image) )
FROM product_image as pi WHERE pi.product_id = products.product_id GROUP BY pi.product_id) as images
END @IF
diff --git a/admin/sql/mysqli/product_attribute.sql b/admin/sql/mysqli/product_attribute.sql
index f3f366a..22331e7 100755
--- a/admin/sql/mysqli/product_attribute.sql
+++ b/admin/sql/mysqli/product_attribute.sql
@@ -51,7 +51,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :product_attribute_data = @FILTER(:product_attribute, product_attribute);
+ :product_attribute_data = @FILTER(:product_attribute, product_attribute)
INSERT INTO product_attribute
@@ -72,7 +72,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_attribute, product_attribute);
+ @FILTER(:product_attribute, product_attribute)
UPDATE product_attribute
diff --git a/admin/sql/mysqli/product_content_revision.sql b/admin/sql/mysqli/product_content_revision.sql
index 0ed80d1..1c4e99c 100644
--- a/admin/sql/mysqli/product_content_revision.sql
+++ b/admin/sql/mysqli/product_content_revision.sql
@@ -100,7 +100,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :product_content_revision_data = @FILTER(:revision, product_content_revision);
+ :product_content_revision_data = @FILTER(:revision, product_content_revision)
INSERT INTO product_content_revision
@@ -123,7 +123,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:revision, product_content_revision);
+ @FILTER(:revision, product_content_revision)
UPDATE product_content_revision
diff --git a/admin/sql/mysqli/product_option.sql b/admin/sql/mysqli/product_option.sql
index 3010337..982f469 100755
--- a/admin/sql/mysqli/product_option.sql
+++ b/admin/sql/mysqli/product_option.sql
@@ -65,7 +65,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :product_option_data = @FILTER(:product_option, product_option);
+ :product_option_data = @FILTER(:product_option, product_option)
INSERT INTO product_option
@@ -86,7 +86,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_option, product_option);
+ @FILTER(:product_option, product_option)
UPDATE product_option
diff --git a/admin/sql/mysqli/product_option_value.sql b/admin/sql/mysqli/product_option_value.sql
index cbd46bb..6926db7 100644
--- a/admin/sql/mysqli/product_option_value.sql
+++ b/admin/sql/mysqli/product_option_value.sql
@@ -82,7 +82,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :product_option_value_data = @FILTER(:product_option_value, product_option_value);
+ :product_option_value_data = @FILTER(:product_option_value, product_option_value)
INSERT INTO product_option_value
@@ -105,7 +105,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :product_option_value_data = @FILTER(:product_option_value, product_option_value);
+ :product_option_value_data = @FILTER(:product_option_value, product_option_value)
UPDATE product_option_value
diff --git a/admin/sql/mysqli/product_question.sql b/admin/sql/mysqli/product_question.sql
index f6f476f..a2d2af4 100755
--- a/admin/sql/mysqli/product_question.sql
+++ b/admin/sql/mysqli/product_question.sql
@@ -83,7 +83,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_question, product_question);
+ @FILTER(:product_question, product_question)
INSERT INTO product_question
@@ -102,7 +102,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_question, product_question);
+ @FILTER(:product_question, product_question)
UPDATE product_question
diff --git a/admin/sql/mysqli/product_review.sql b/admin/sql/mysqli/product_review.sql
index 0de8b3e..6fcde84 100755
--- a/admin/sql/mysqli/product_review.sql
+++ b/admin/sql/mysqli/product_review.sql
@@ -168,7 +168,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_review, product_review);
+ @FILTER(:product_review, product_review)
INSERT INTO product_review
@@ -187,7 +187,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_review, product_review);
+ @FILTER(:product_review, product_review)
UPDATE product_review
diff --git a/admin/sql/mysqli/product_review_media.sql b/admin/sql/mysqli/product_review_media.sql
index 0876d5a..57d8b0a 100644
--- a/admin/sql/mysqli/product_review_media.sql
+++ b/admin/sql/mysqli/product_review_media.sql
@@ -80,7 +80,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_review_media, product_review_media);
+ @FILTER(:product_review_media, product_review_media)
INSERT INTO product_review_media
@@ -99,7 +99,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_review_media, product_review_media);
+ @FILTER(:product_review_media, product_review_media)
UPDATE product_review_media
diff --git a/admin/sql/mysqli/product_subscription.sql b/admin/sql/mysqli/product_subscription.sql
index 5549fb5..7d43fe5 100644
--- a/admin/sql/mysqli/product_subscription.sql
+++ b/admin/sql/mysqli/product_subscription.sql
@@ -79,7 +79,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :product_subscription_data = @FILTER(:product_subscription, product_subscription);
+ :product_subscription_data = @FILTER(:product_subscription, product_subscription)
INSERT INTO product_subscription
@@ -100,7 +100,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_subscription, product_subscription);
+ @FILTER(:product_subscription, product_subscription)
UPDATE product_subscription
diff --git a/admin/sql/mysqli/region.sql b/admin/sql/mysqli/region.sql
index 49572c9..98d843b 100755
--- a/admin/sql/mysqli/region.sql
+++ b/admin/sql/mysqli/region.sql
@@ -74,7 +74,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :region_data = @FILTER(:region, region);
+ :region_data = @FILTER(:region, region)
INSERT INTO region
@@ -95,7 +95,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:region, region);
+ @FILTER(:region, region)
UPDATE region
diff --git a/admin/sql/mysqli/region_group.sql b/admin/sql/mysqli/region_group.sql
index e05ca6b..e1cd79b 100755
--- a/admin/sql/mysqli/region_group.sql
+++ b/admin/sql/mysqli/region_group.sql
@@ -81,7 +81,7 @@
DELETE FROM region_to_region_group WHERE region_group_id = :region_group_id;
-- allow only table fields and set defaults for missing values
- :region_to_region_group_data = @FILTER(:region_to_region_group, region_to_region_group);
+ :region_to_region_group_data = @FILTER(:region_to_region_group, region_to_region_group)
@EACH(:region_to_region_group_data)
@@ -116,7 +116,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :region_group_data = @FILTER(:region_group, region_group);
+ :region_group_data = @FILTER(:region_group, region_group)
INSERT INTO region_group
@@ -137,7 +137,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:region_group, region_group);
+ @FILTER(:region_group, region_group)
UPDATE region_group
diff --git a/admin/sql/mysqli/return.sql b/admin/sql/mysqli/return.sql
index f7abfa4..6a08f86 100755
--- a/admin/sql/mysqli/return.sql
+++ b/admin/sql/mysqli/return.sql
@@ -57,7 +57,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :return_data = @FILTER(:return, return);
+ :return_data = @FILTER(:return, return)
INSERT INTO `return`
@@ -77,7 +77,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:return, return);
+ @FILTER(:return, return)
UPDATE `return`
diff --git a/admin/sql/mysqli/return_reason.sql b/admin/sql/mysqli/return_reason.sql
index 18978b9..1624d4a 100755
--- a/admin/sql/mysqli/return_reason.sql
+++ b/admin/sql/mysqli/return_reason.sql
@@ -51,7 +51,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :return_reason_data = @FILTER(:return_reason, return_reason);
+ :return_reason_data = @FILTER(:return_reason, return_reason)
INSERT INTO return_reason
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:return_reason, return_reason);
+ @FILTER(:return_reason, return_reason)
UPDATE return_reason
diff --git a/admin/sql/mysqli/return_resolution.sql b/admin/sql/mysqli/return_resolution.sql
index 944d206..83f7f22 100755
--- a/admin/sql/mysqli/return_resolution.sql
+++ b/admin/sql/mysqli/return_resolution.sql
@@ -51,7 +51,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :return_resolution_data = @FILTER(:return_resolution, return_resolution);
+ :return_resolution_data = @FILTER(:return_resolution, return_resolution)
INSERT INTO return_resolution
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:return_resolution, return_resolution);
+ @FILTER(:return_resolution, return_resolution)
UPDATE return_resolution
diff --git a/admin/sql/mysqli/return_status.sql b/admin/sql/mysqli/return_status.sql
index 39d74d4..c8ed13c 100755
--- a/admin/sql/mysqli/return_status.sql
+++ b/admin/sql/mysqli/return_status.sql
@@ -51,7 +51,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :return_status_data = @FILTER(:return_status, return_status);
+ :return_status_data = @FILTER(:return_status, return_status)
INSERT INTO return_status
@@ -72,7 +72,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:return_status, return_status);
+ @FILTER(:return_status, return_status)
UPDATE return_status
diff --git a/admin/sql/mysqli/role.sql b/admin/sql/mysqli/role.sql
index fa5da55..f07f014 100755
--- a/admin/sql/mysqli/role.sql
+++ b/admin/sql/mysqli/role.sql
@@ -56,7 +56,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:role, role);
+ @FILTER(:role, role)
INSERT INTO role
@@ -75,7 +75,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:role, role);
+ @FILTER(:role, role)
UPDATE role
diff --git a/admin/sql/mysqli/setting.sql b/admin/sql/mysqli/setting.sql
index 1ed321c..cc7422c 100755
--- a/admin/sql/mysqli/setting.sql
+++ b/admin/sql/mysqli/setting.sql
@@ -2,17 +2,17 @@
-- get one setting
- CREATE PROCEDURE getSetting(
+ CREATE PROCEDURE get(
+ IN site_id INT,
IN namespace CHAR,
IN key CHAR,
- IN site_id INT,
OUT fetch_one,
)
BEGIN
SELECT value
- FROM setting AS _
+ FROM setting AS _
WHERE _.`key` = :key
@IF !empty(:namespace)
@@ -28,49 +28,44 @@
END
- CREATE PROCEDURE setSetting(
+ CREATE PROCEDURE set(
+ IN site_id INT,
IN namespace CHAR,
IN key CHAR,
IN value CHAR,
- IN site_id INT,
OUT insert_id
)
BEGIN
- INSERT INTO setting
- (namespace, `key`, value, site_id)
+ INSERT INTO setting
+ (site_id, namespace, `key`, value)
- VALUES ( :namespace, :key, :value, :site_id )
+ VALUES ( :site_id, :namespace, :key, :value )
ON DUPLICATE KEY
UPDATE value = values(value);
END
-
- CREATE PROCEDURE delete(
- IN namespace CHAR,
- IN key CHAR,
- )
- BEGIN
- DELETE FROM
- setting
- WHERE `key` = :key;
-
- END
- CREATE PROCEDURE getSettings(
+ CREATE PROCEDURE getMulti(
+ IN site_id INT,
IN namespace CHAR,
IN key ARRAY,
- IN site_id INT,
- OUT fetch_all,
+ OUT fetch_all
)
BEGIN
SELECT namespace, `key`, value
- FROM setting AS _
+ FROM setting AS _
WHERE 1 = 1
+
+
+ @IF !empty(:site_id)
+ THEN
+ AND _.site_id = :site_id
+ END @IF
@IF !empty(:namespace)
THEN
@@ -79,59 +74,60 @@
@IF !empty(:key)
THEN
- AND _.`key`IN (:key)
- END @IF
-
- @IF !empty(:site_id)
- THEN
- AND _.site_id = :site_id
+ AND _.`key` IN (:key)
END @IF
;
END
- CREATE PROCEDURE setSettings(
+ CREATE PROCEDURE setMulti(
+ IN site_id INT,
IN namespace CHAR,
IN settings ARRAY,
- IN site_id INT,
+
+ OUT insert_id
)
BEGIN
- INSERT INTO setting
- (namespace, `key`, value, site_id)
-
- -- @EACH(:settings)
- VALUES (namespace, :each, :site_id)
- -- END @EACH
+ -- :settings = @FILTER(:settings, setting, false, true)
+
+ @EACH(:settings)
+ INSERT INTO setting
- -- @VALUES(:settings) --@VALUES expands the array to the following expression
- -- ( :settings.each.`key`, :settings.each.value, :site_id )
+ ( site_id, namespace, `key`, value )
+
+ VALUES ( :site_id, :namespace, :each_key, :each )
ON DUPLICATE KEY
UPDATE value = VALUES(value);
END
- CREATE PROCEDURE deleteSettings(
- IN namespace CHAR,
- IN keys ARRAY,
+ CREATE PROCEDURE delete(
IN site_id,
+ IN namespace CHAR,
+ IN key ARRAY
)
BEGIN
- DELETE FROM
- setting
- WHERE `key` IN (:keys)
+ DELETE FROM
+ setting
+ WHERE 1 = 1
@IF !empty(:namespace)
THEN
- AND _.namespace = :namespace
+ AND namespace = :namespace
+ END @IF
+
+ @IF !empty(:key)
+ THEN
+ AND `key` IN (:key)
END @IF
@IF !empty(:site_id)
THEN
- AND _.site_id = :site_id
+ AND site_id = :site_id
END @IF
;
diff --git a/admin/sql/mysqli/setting_content.sql b/admin/sql/mysqli/setting_content.sql
index f0ac823..b010ea9 100755
--- a/admin/sql/mysqli/setting_content.sql
+++ b/admin/sql/mysqli/setting_content.sql
@@ -1,36 +1,50 @@
--- Setting contents
+-- Setting content
-- get one setting content
CREATE PROCEDURE get(
- IN key ARRAY,
IN site_id INT,
+ IN namespace CHAR,
+ IN key CHAR,
IN language_id INT,
+
+ OUT fetch_one
)
BEGIN
SELECT `key`, value
- FROM setting_content AS _
- WHERE _.keyIN (:key)
+ FROM setting_content AS _
+ WHERE 1 = 1
- @IF !empty(:language_id)
+ @IF !empty(:site_id)
THEN
AND _.site_id = :site_id
+ END @IF
+
+ @IF !empty(:namespace)
+ THEN
+ AND _.namespace = :namespace
+ END @IF
+
+ @IF !empty(:key)
+ THEN
+ AND _.`key` = :key
END @IF
@IF !empty(:language_id)
THEN
AND _.language_id = :language_id
END @IF
+ ;
END
-
- CREATE PROCEDURE _set(
+ CREATE PROCEDURE set(
+ IN site_id INT,
+ IN namespace CHAR,
IN key CHAR,
IN value CHAR,
- IN site_id INT,
IN language_id INT,
OUT insert_id
@@ -38,7 +52,7 @@
BEGIN
INSERT INTO setting_content
- (`key`, value, site_id, language_id)
+ (`namespace`,`key`, value, site_id, language_id)
VALUES ( :key, :value, :site_id , :language_id )
@@ -47,39 +61,95 @@
END
-
-
- CREATE PROCEDURE set(
- IN setting_content ARRAY,
+ CREATE PROCEDURE getMulti(
IN site_id INT,
+ IN namespace CHAR,
+ IN key ARRAY,
IN language_id INT,
+
+ OUT fetch_all
)
BEGIN
- INSERT INTO setting_content
- (`key`, value, site_id, language_id)
-
- -- @EACH(:setting_contents)
- VALUES ( :each, :site_id, :language_id)
- -- END @EACH
+ SELECT site_id, namespace, `key`, value, language_id
+ FROM setting_content AS _
+ WHERE 1 = 1
- -- @VALUES(:setting_contents) --@VALUES expands the array to the following expression
- -- ( :setting_contents.each.key, :setting_contents.each.value, :site_id )
-
- ON DUPLICATE KEY
- UPDATE value = VALUES(value);
+ @IF !empty(:site_id)
+ THEN
+ AND _.site_id = :site_id
+ END @IF
+
+ @IF !empty(:namespace)
+ THEN
+ AND _.namespace = :namespace
+ END @IF
+
+ @IF !empty(:key)
+ THEN
+ AND _.`key` IN (:key)
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND _.language_id = :language_id
+ END @IF
+ ;
+
+ END
+
+
+ CREATE PROCEDURE setMulti(
+ IN site_id INT,
+ IN meta ARRAY,
+
+ OUT insert_id
+ )
+ BEGIN
+
+ :meta = @FILTER(:meta, setting_content, false, true)
+
+ @EACH(:meta)
+ INSERT INTO setting_content
+
+ ( @KEYS(:each), site_id)
+
+ VALUES ( :each, :site_id )
+ ON DUPLICATE KEY
+ UPDATE value = VALUES(value);
END
CREATE PROCEDURE delete(
- IN keys ARRAY,
IN site_id,
- IN language_id INT,
+ IN namespace CHAR,
+ IN key ARRAY,
+ IN language_id INT
)
BEGIN
- DELETE FROM
- setting_content
- WHERE `key` IN (:keys) AND site_id = :site_id AND language_id = :language_id;
+ DELETE FROM
+ setting_content
+ WHERE 1 = 1
+ @IF !empty(:namespace)
+ THEN
+ AND namespace = :namespace
+ END @IF
+
+ @IF !empty(:key)
+ THEN
+ AND `key` IN (:key)
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND language_id = :language_id
+ END @IF
+
+ @IF !empty(:site_id)
+ THEN
+ AND site_id = :site_id
+ END @IF
+ ;
END
diff --git a/admin/sql/mysqli/site.sql b/admin/sql/mysqli/site.sql
index 2070615..e2875f4 100755
--- a/admin/sql/mysqli/site.sql
+++ b/admin/sql/mysqli/site.sql
@@ -17,7 +17,7 @@
SELECT *, site_id as array_key
FROM site as sites
- WHERE 1
+ WHERE 1 = 1
-- site_id
@IF isset(:site_id) && !empty(:site_id)
@@ -129,7 +129,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :site_data = @FILTER(:site, site);
+ :site_data = @FILTER(:site, site)
INSERT INTO site
@@ -149,7 +149,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :site_data = @FILTER(:site, site);
+ :site_data = @FILTER(:site, site)
UPDATE site
@@ -182,4 +182,4 @@
DELETE FROM vendor_to_site WHERE site_id IN (:site_id);
DELETE FROM site WHERE site_id IN (:site_id);
- END
\ No newline at end of file
+ END
diff --git a/admin/sql/mysqli/stat.sql b/admin/sql/mysqli/stat.sql
index 5846410..99b0250 100755
--- a/admin/sql/mysqli/stat.sql
+++ b/admin/sql/mysqli/stat.sql
@@ -20,7 +20,7 @@
-- orders
- SELECT COUNT(*) AS orders, DATE(created_at) as date, orders.created_at FROM `order` AS orders
+ SELECT COUNT(*) AS orders, DATE(created_at) as date FROM `order` AS orders
LEFT JOIN order_status AS os ON (orders.order_status_id = os.order_status_id AND os.language_id = :language_id)
@@ -45,12 +45,12 @@
END @IF
- GROUP BY date,orders.created_at ORDER BY date;
+ GROUP BY date ORDER BY date;
-- users
- SELECT COUNT(*) AS users, DATE(created_at) as date, users.created_at FROM `user` AS users
+ SELECT COUNT(*) AS users, DATE(created_at) as date FROM `user` AS users
WHERE 1 = 1
@@ -66,7 +66,7 @@
END @IF
- GROUP BY date, users.created_at ORDER BY date;
+ GROUP BY date ORDER BY date;
END
diff --git a/admin/sql/mysqli/stock_status.sql b/admin/sql/mysqli/stock_status.sql
index 9c490d3..71ce0f6 100755
--- a/admin/sql/mysqli/stock_status.sql
+++ b/admin/sql/mysqli/stock_status.sql
@@ -51,7 +51,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :stock_status_data = @FILTER(:stock_status, stock_status);
+ :stock_status_data = @FILTER(:stock_status, stock_status)
INSERT INTO stock_status
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:stock_status, stock_status);
+ @FILTER(:stock_status, stock_status)
UPDATE stock_status
diff --git a/admin/sql/mysqli/subscription.sql b/admin/sql/mysqli/subscription.sql
index bf6004b..952bfeb 100755
--- a/admin/sql/mysqli/subscription.sql
+++ b/admin/sql/mysqli/subscription.sql
@@ -49,7 +49,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :subscription_data = @FILTER(:subscription, subscription);
+ :subscription_data = @FILTER(:subscription, subscription)
INSERT INTO subscription
@@ -70,7 +70,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:subscription, subscription);
+ @FILTER(:subscription, subscription)
UPDATE subscription
diff --git a/admin/sql/mysqli/subscription_plan.sql b/admin/sql/mysqli/subscription_plan.sql
index ab6ba84..53193e7 100755
--- a/admin/sql/mysqli/subscription_plan.sql
+++ b/admin/sql/mysqli/subscription_plan.sql
@@ -56,7 +56,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :subscription_plan_data = @FILTER(:subscription_plan, subscription_plan);
+ :subscription_plan_data = @FILTER(:subscription_plan, subscription_plan)
INSERT INTO subscription_plan
@@ -77,7 +77,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:subscription_plan, subscription_plan);
+ @FILTER(:subscription_plan, subscription_plan)
UPDATE subscription_plan
diff --git a/admin/sql/mysqli/subscription_status.sql b/admin/sql/mysqli/subscription_status.sql
index 1fa588b..b50fb65 100755
--- a/admin/sql/mysqli/subscription_status.sql
+++ b/admin/sql/mysqli/subscription_status.sql
@@ -51,7 +51,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :subscription_status_data = @FILTER(:subscription_status, subscription_status);
+ :subscription_status_data = @FILTER(:subscription_status, subscription_status)
INSERT INTO subscription_status
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:subscription_status, subscription_status);
+ @FILTER(:subscription_status, subscription_status)
UPDATE subscription_status
diff --git a/admin/sql/mysqli/tax_rate.sql b/admin/sql/mysqli/tax_rate.sql
index 2dc96e1..8ab847c 100755
--- a/admin/sql/mysqli/tax_rate.sql
+++ b/admin/sql/mysqli/tax_rate.sql
@@ -51,7 +51,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :tax_rate_data = @FILTER(:tax_rate, tax_rate);
+ :tax_rate_data = @FILTER(:tax_rate, tax_rate)
INSERT INTO tax_rate
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:tax_rate, tax_rate);
+ @FILTER(:tax_rate, tax_rate)
UPDATE tax_rate
diff --git a/admin/sql/mysqli/tax_rule.sql b/admin/sql/mysqli/tax_rule.sql
index 512501e..9c0c441 100755
--- a/admin/sql/mysqli/tax_rule.sql
+++ b/admin/sql/mysqli/tax_rule.sql
@@ -60,7 +60,7 @@
DELETE FROM tax_rule WHERE tax_type_id = :tax_type_id;
-- allow only table fields and set defaults for missing values
- :tax_rule_data = @FILTER(:tax_rule, tax_rule);
+ :tax_rule_data = @FILTER(:tax_rule, tax_rule)
@EACH(:tax_rule_data)
@@ -84,7 +84,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:tax_rule, tax_rule);
+ @FILTER(:tax_rule, tax_rule)
UPDATE tax_rule
diff --git a/admin/sql/mysqli/tax_type.sql b/admin/sql/mysqli/tax_type.sql
index 73c361b..d956d74 100755
--- a/admin/sql/mysqli/tax_type.sql
+++ b/admin/sql/mysqli/tax_type.sql
@@ -81,7 +81,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :tax_type_data = @FILTER(:tax_type, tax_type);
+ :tax_type_data = @FILTER(:tax_type, tax_type)
INSERT INTO tax_type
@@ -101,7 +101,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:tax_type, tax_type);
+ @FILTER(:tax_type, tax_type)
UPDATE tax_type
diff --git a/admin/sql/mysqli/taxonomy.sql b/admin/sql/mysqli/taxonomy.sql
index 2822b22..3c83f3f 100755
--- a/admin/sql/mysqli/taxonomy.sql
+++ b/admin/sql/mysqli/taxonomy.sql
@@ -73,7 +73,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :taxonomy_data = @FILTER(:taxonomy, taxonomy);
+ :taxonomy_data = @FILTER(:taxonomy, taxonomy)
INSERT INTO taxonomy
@@ -93,7 +93,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:taxonomy, taxonomy);
+ @FILTER(:taxonomy, taxonomy)
UPDATE taxonomy
diff --git a/admin/sql/mysqli/taxonomy_item.sql b/admin/sql/mysqli/taxonomy_item.sql
index bfe62a9..f95ad68 100755
--- a/admin/sql/mysqli/taxonomy_item.sql
+++ b/admin/sql/mysqli/taxonomy_item.sql
@@ -44,7 +44,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :taxonomy_item_data = @FILTER(:taxonomy_item, taxonomy_item);
+ :taxonomy_item_data = @FILTER(:taxonomy_item, taxonomy_item)
INSERT INTO taxonomy_item
@@ -64,7 +64,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:taxonomy_item, taxonomy_item);
+ @FILTER(:taxonomy_item, taxonomy_item)
UPDATE taxonomy_item
diff --git a/admin/sql/mysqli/user.sql b/admin/sql/mysqli/user.sql
index 3cb99f4..05a11cb 100755
--- a/admin/sql/mysqli/user.sql
+++ b/admin/sql/mysqli/user.sql
@@ -111,7 +111,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user, user);
+ @FILTER(:user, user)
INSERT INTO user
@@ -132,7 +132,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user, user);
+ @FILTER(:user, user)
UPDATE user
diff --git a/admin/sql/mysqli/user_address.sql b/admin/sql/mysqli/user_address.sql
index 6682210..fb26c1f 100755
--- a/admin/sql/mysqli/user_address.sql
+++ b/admin/sql/mysqli/user_address.sql
@@ -74,7 +74,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user_address, user_address);
+ @FILTER(:user_address, user_address)
INSERT INTO user_address
@@ -94,7 +94,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user_address, user_address);
+ @FILTER(:user_address, user_address)
UPDATE user_address
diff --git a/admin/sql/mysqli/user_group.sql b/admin/sql/mysqli/user_group.sql
index fc86caa..a5e7c3b 100755
--- a/admin/sql/mysqli/user_group.sql
+++ b/admin/sql/mysqli/user_group.sql
@@ -63,7 +63,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :user_group_data = @FILTER(:user_group, user_group);
+ :user_group_data = @FILTER(:user_group, user_group)
INSERT INTO user_group
@@ -71,7 +71,7 @@
VALUES ( :user_group_data );
- :user_group_content = @FILTER(:user_group, user_group_content);
+ :user_group_content = @FILTER(:user_group, user_group_content)
INSERT INTO user_group_content
@@ -91,7 +91,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :user_group_data = @FILTER(:user_group, user_group);
+ :user_group_data = @FILTER(:user_group, user_group)
UPDATE user_group
@@ -100,7 +100,7 @@
WHERE user_group_id = :user_group_id;
-- allow only table fields and set defaults for missing values
- :user_group_content = @FILTER(:user_group, user_group_content);
+ :user_group_content = @FILTER(:user_group, user_group_content)
UPDATE user_group_content
diff --git a/admin/sql/mysqli/user_wishlist.sql b/admin/sql/mysqli/user_wishlist.sql
index a3ca6f3..689547b 100644
--- a/admin/sql/mysqli/user_wishlist.sql
+++ b/admin/sql/mysqli/user_wishlist.sql
@@ -62,7 +62,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user_wishlist, user_wishlist);
+ @FILTER(:user_wishlist, user_wishlist)
INSERT INTO user_wishlist
diff --git a/admin/sql/mysqli/vendor.sql b/admin/sql/mysqli/vendor.sql
index 7a841df..abb7718 100755
--- a/admin/sql/mysqli/vendor.sql
+++ b/admin/sql/mysqli/vendor.sql
@@ -47,7 +47,7 @@
-- SELECT * FROM vendor_option WHERE vendor_id = :vendor_id;
-- allow only table fields and set defaults for missing values
- @FILTER(:vendor, vendor);
+ @FILTER(:vendor, vendor)
UPDATE vendor
@@ -67,7 +67,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :vendor = @FILTER(:vendor, vendor);
+ :vendor = @FILTER(:vendor, vendor)
INSERT INTO vendor
diff --git a/admin/sql/mysqli/voucher.sql b/admin/sql/mysqli/voucher.sql
index 12061c2..1abacb8 100755
--- a/admin/sql/mysqli/voucher.sql
+++ b/admin/sql/mysqli/voucher.sql
@@ -46,7 +46,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :voucher_data = @FILTER(:voucher, voucher);
+ :voucher_data = @FILTER(:voucher, voucher)
INSERT INTO voucher
@@ -66,7 +66,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:voucher, voucher);
+ @FILTER(:voucher, voucher)
UPDATE voucher
diff --git a/admin/sql/mysqli/weight_type.sql b/admin/sql/mysqli/weight_type.sql
index ddec844..9607c08 100755
--- a/admin/sql/mysqli/weight_type.sql
+++ b/admin/sql/mysqli/weight_type.sql
@@ -64,7 +64,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :weight_type_data = @FILTER(:weight_type, weight_type);
+ :weight_type_data = @FILTER(:weight_type, weight_type)
INSERT INTO weight_type
@@ -73,7 +73,7 @@
VALUES ( :weight_type_data);
-- allow only table fields and set defaults for missing values
- :weight_type_content_data = @FILTER(:weight_type, weight_type_content);
+ :weight_type_content_data = @FILTER(:weight_type, weight_type_content)
INSERT INTO weight_type_content
@@ -93,7 +93,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :weight_type_data = @FILTER(:weight_type, weight_type);
+ :weight_type_data = @FILTER(:weight_type, weight_type)
UPDATE weight_type
@@ -102,7 +102,7 @@
WHERE weight_type_id = :weight_type_id;
-- allow only table fields and set defaults for missing values
- :weight_type_content_data = @FILTER(:weight_type, weight_type_content);
+ :weight_type_content_data = @FILTER(:weight_type, weight_type_content)
UPDATE weight_type_content