Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Changed json generation with CONCAT to json_group_array and json_object, fixed menu and categories queries, removed redundant ; from @FILTER

givanzff30a0b40fe9
diff --git a/admin/sql/sqlite/admin.sql b/admin/sql/sqlite/admin.sql
index 991100b..83d23c1 100755
--- a/admin/sql/sqlite/admin.sql
+++ b/admin/sql/sqlite/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/sqlite/attribute.sql b/admin/sql/sqlite/attribute.sql
index f3a8e8e..f017c73 100755
--- a/admin/sql/sqlite/attribute.sql
+++ b/admin/sql/sqlite/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/sqlite/attribute_group.sql b/admin/sql/sqlite/attribute_group.sql
index 40da1b4..f42cb70 100755
--- a/admin/sql/sqlite/attribute_group.sql
+++ b/admin/sql/sqlite/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/sqlite/category.sql b/admin/sql/sqlite/category.sql
index fa21557..36d277d 100755
--- a/admin/sql/sqlite/category.sql
+++ b/admin/sql/sqlite/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,7 +153,7 @@
-- return array of categories for categories query
OUT fetch_all,
-- return categories count for count query
- OUT fetch_one,
+ OUT fetch_one
)
BEGIN
@@ -247,7 +247,7 @@
IN post_type CHAR,
IN type CHAR,
IN slug CHAR,
- OUT fetch_row,
+ OUT fetch_row
)
BEGIN
-- taxonomy_item
@@ -331,7 +331,7 @@
IN language_id INT,
IN post_type CHAR,
IN slug CHAR,
- OUT fetch_row,
+ OUT fetch_row
)
BEGIN
@@ -409,7 +409,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
@@ -422,7 +422,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
@@ -441,27 +441,20 @@
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
( @KEYS(:taxonomy_item) )
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
@@ -476,8 +469,6 @@
VALUES ( @result.taxonomy_item, :site_id );
-
- SELECT @taxonomy_item_id as taxonomy_item_id;
END
@@ -498,21 +489,30 @@
-- return array of categories for categories query
OUT fetch_all,
-- return categories count for count query
- OUT fetch_one,
+ OUT fetch_one
)
BEGIN
SELECT *,
(
SELECT
- '[' || GROUP_CONCAT(
- '{"language_id":"' || tc.language_id||
- '","name":"' || tc.name||
- '","slug":"' || tc.slug||
- '","content":"' || tc.content||
- '","meta_title":"' || tc.meta_title||
- '","meta_description":"' || tc.meta_description||
- '","meta_keywords":"' || tc.meta_keywords || '"}'|| '') || ']'
+ -- '[' || GROUP_CONCAT(
+ -- '{"language_id":"' || tc.language_id||
+ -- '","name":"' || tc.name||
+ -- '","slug":"' || tc.slug||
+ -- '","content":"' || tc.content||
+ -- '","meta_title":"' || tc.meta_title||
+ -- '","meta_description":"' || tc.meta_description||
+ -- '","meta_keywords":"' || tc.meta_keywords || '"}'|| '') || ']'
+
+ json_group_array(json_object(
+ 'language_id', tc.language_id,
+ 'name' , tc.name,
+ 'slug' , tc.slug,
+ 'content' , tc.content,
+ 'meta_title' , tc.meta_title,
+ 'meta_description' , tc.meta_description,
+ 'meta_keywords' , tc.meta_keywords) )
FROM taxonomy_item_content as tc
WHERE
@@ -582,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
@@ -591,11 +591,10 @@
VALUES ( :each, :taxonomy_item_id)
ON CONFLICT(`taxonomy_item_id`,`language_id`)
- DO UPDATE SET @LIST(:each)
- WHERE taxonomy_item_id = :taxonomy_item_id AND language_id = :each.language_id;
+ DO UPDATE SET @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
@@ -611,13 +610,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
@@ -639,8 +639,6 @@
VALUES ( @result.taxonomy_item, :each );
-
- SELECT @taxonomy_item as taxonomy_item;
END
@@ -652,7 +650,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/sqlite/comment.sql b/admin/sql/sqlite/comment.sql
index 9638cf3..814c217 100755
--- a/admin/sql/sqlite/comment.sql
+++ b/admin/sql/sqlite/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/sqlite/country.sql b/admin/sql/sqlite/country.sql
index 07136b6..a8201e4 100755
--- a/admin/sql/sqlite/country.sql
+++ b/admin/sql/sqlite/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/sqlite/coupon.sql b/admin/sql/sqlite/coupon.sql
index bfbeaff..b1ac2a9 100755
--- a/admin/sql/sqlite/coupon.sql
+++ b/admin/sql/sqlite/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/sqlite/currency.sql b/admin/sql/sqlite/currency.sql
index 553e82b..b1cce0b 100755
--- a/admin/sql/sqlite/currency.sql
+++ b/admin/sql/sqlite/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/sqlite/digital_asset.sql b/admin/sql/sqlite/digital_asset.sql
index faa37f9..bba42e3 100755
--- a/admin/sql/sqlite/digital_asset.sql
+++ b/admin/sql/sqlite/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/sqlite/field_group.sql b/admin/sql/sqlite/field_group.sql
index 88290d8..8a18f95 100755
--- a/admin/sql/sqlite/field_group.sql
+++ b/admin/sql/sqlite/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/sqlite/language.sql b/admin/sql/sqlite/language.sql
index 4613242..603ce0c 100755
--- a/admin/sql/sqlite/language.sql
+++ b/admin/sql/sqlite/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/sqlite/length_type.sql b/admin/sql/sqlite/length_type.sql
index 56e44d2..a3558b8 100755
--- a/admin/sql/sqlite/length_type.sql
+++ b/admin/sql/sqlite/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/sqlite/manufacturer.sql b/admin/sql/sqlite/manufacturer.sql
index 663e8c9..e512196 100755
--- a/admin/sql/sqlite/manufacturer.sql
+++ b/admin/sql/sqlite/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/sqlite/menu.sql b/admin/sql/sqlite/menu.sql
index f7cc282..732bcc4 100755
--- a/admin/sql/sqlite/menu.sql
+++ b/admin/sql/sqlite/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
@@ -270,7 +270,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
@@ -279,12 +279,11 @@
VALUES ( :each, :menu_item_id)
ON CONFLICT(`menu_item_id`,`language_id`)
- DO UPDATE SET @LIST(:each)
- WHERE menu_item_id = :menu_item_id AND language_id = :each.language_id;
+ DO UPDATE SET @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
@@ -299,13 +298,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
@@ -321,8 +321,6 @@
VALUES ( @result.menu_item, :each );
-
- SELECT @menu_item as menu_item;
END
-- Reorder menu items
@@ -333,7 +331,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
@@ -344,9 +342,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,
@@ -387,4 +385,22 @@
)
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 menu_item WHERE parent_id = :menu_item_id);
+ DELETE FROM menu_item WHERE menu_item_id = :menu_item_id;
+
END
diff --git a/admin/sql/sqlite/option.sql b/admin/sql/sqlite/option.sql
index 40ef7f7..98e579b 100644
--- a/admin/sql/sqlite/option.sql
+++ b/admin/sql/sqlite/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/sqlite/option_value.sql b/admin/sql/sqlite/option_value.sql
index 38c3f89..f34eb7e 100644
--- a/admin/sql/sqlite/option_value.sql
+++ b/admin/sql/sqlite/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/sqlite/order.sql b/admin/sql/sqlite/order.sql
index 0dd0d28..fd713d7 100755
--- a/admin/sql/sqlite/order.sql
+++ b/admin/sql/sqlite/order.sql
@@ -267,9 +267,9 @@
)
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 +287,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 +306,7 @@
)
BEGIN
- @FILTER(:order, order);
+ @FILTER(:order, order)
UPDATE `order`
diff --git a/admin/sql/sqlite/order_log.sql b/admin/sql/sqlite/order_log.sql
index 3c0d0c1..6814bd9 100644
--- a/admin/sql/sqlite/order_log.sql
+++ b/admin/sql/sqlite/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/sqlite/order_status.sql b/admin/sql/sqlite/order_status.sql
index 49a7e83..bcf04ab 100755
--- a/admin/sql/sqlite/order_status.sql
+++ b/admin/sql/sqlite/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/sqlite/post.sql b/admin/sql/sqlite/post.sql
index bad66f5..31a2cd7 100755
--- a/admin/sql/sqlite/post.sql
+++ b/admin/sql/sqlite/post.sql
@@ -270,13 +270,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
@@ -285,7 +288,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)
@@ -303,11 +306,12 @@
VALUES ( :each, @result.post)
ON CONFLICT(`post_id`,`taxonomy_item_id`) DO UPDATE SET `taxonomy_item_id` = :each;
+ @EACH(:site_id)
INSERT INTO post_to_site
( `post_id`, `site_id` )
- VALUES ( @result.post, :site_id );
+ VALUES ( @result.post, :each );
END
@@ -316,12 +320,12 @@
CREATE PROCEDURE edit(
IN post ARRAY,
IN post_id INT,
- IN site_id INT,
+ IN site_id ARRAY,
OUT affected_rows
)
BEGIN
BEGIN TRANSACTION;
- :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
@@ -332,10 +336,10 @@
ON CONFLICT(post_id, language_id) DO UPDATE SET @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
@@ -345,17 +349,21 @@
VALUES ( :each, :post_id)
ON CONFLICT(`post_id`,`taxonomy_item_id`) DO UPDATE SET `taxonomy_item_id` = :each;
- -- END @IF
+ @IF isset(:site_id)
+ THEN
+ DELETE FROM post_to_site WHERE post_id = :post_id
+ END @IF;
- INSERT OR IGNORE INTO post_to_site
+ @EACH(:site_id)
+ INSERT INTO post_to_site
( `post_id`, `site_id` )
- VALUES ( :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
@@ -380,7 +388,7 @@
)
BEGIN
- :post_content = @FILTER(:post_content, post_content);
+ :post_content = @FILTER(:post_content, post_content)
UPDATE post_content
@@ -395,9 +403,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/sqlite/post_content_revision.sql b/admin/sql/sqlite/post_content_revision.sql
index a8f8341..77df20b 100644
--- a/admin/sql/sqlite/post_content_revision.sql
+++ b/admin/sql/sqlite/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/sqlite/product.sql b/admin/sql/sqlite/product.sql
index 64432a6..5e204ed 100755
--- a/admin/sql/sqlite/product.sql
+++ b/admin/sql/sqlite/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 CONFLICT("product_id", "language_id") DO UPDATE SET @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 CONFLICT("taxonomy_item_id", "product_id") DO UPDATE SET "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
@@ -505,13 +523,14 @@
-- UPDATE product SET image = :image WHERE product_id = :product_id;
- -- :product = @FILTER(:product_data, product);
+ -- :product = @FILTER(:product_data, product)
+ @EACH(:site_id)
INSERT INTO product_to_site
( product_id, site_id )
- VALUES ( @result.product, :site_id );
+ VALUES ( @result.product, :each );
END
diff --git a/admin/sql/sqlite/product_attribute.sql b/admin/sql/sqlite/product_attribute.sql
index f3f366a..22331e7 100755
--- a/admin/sql/sqlite/product_attribute.sql
+++ b/admin/sql/sqlite/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/sqlite/product_content_revision.sql b/admin/sql/sqlite/product_content_revision.sql
index 0ed80d1..1c4e99c 100644
--- a/admin/sql/sqlite/product_content_revision.sql
+++ b/admin/sql/sqlite/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/sqlite/product_option.sql b/admin/sql/sqlite/product_option.sql
index 3010337..982f469 100755
--- a/admin/sql/sqlite/product_option.sql
+++ b/admin/sql/sqlite/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/sqlite/product_option_value.sql b/admin/sql/sqlite/product_option_value.sql
index cbd46bb..6926db7 100644
--- a/admin/sql/sqlite/product_option_value.sql
+++ b/admin/sql/sqlite/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/sqlite/product_question.sql b/admin/sql/sqlite/product_question.sql
index 2fa2b42..48d443e 100755
--- a/admin/sql/sqlite/product_question.sql
+++ b/admin/sql/sqlite/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/sqlite/product_review.sql b/admin/sql/sqlite/product_review.sql
index e823fe9..d8f69ab 100755
--- a/admin/sql/sqlite/product_review.sql
+++ b/admin/sql/sqlite/product_review.sql
@@ -167,7 +167,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
@@ -186,7 +186,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/sqlite/product_review_media.sql b/admin/sql/sqlite/product_review_media.sql
index e8f1b34..f2c3a3d 100644
--- a/admin/sql/sqlite/product_review_media.sql
+++ b/admin/sql/sqlite/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/sqlite/product_subscription.sql b/admin/sql/sqlite/product_subscription.sql
index ca4c8e3..c79bca5 100644
--- a/admin/sql/sqlite/product_subscription.sql
+++ b/admin/sql/sqlite/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/sqlite/region.sql b/admin/sql/sqlite/region.sql
index dd94a32..edacba3 100755
--- a/admin/sql/sqlite/region.sql
+++ b/admin/sql/sqlite/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/sqlite/region_group.sql b/admin/sql/sqlite/region_group.sql
index 816fe61..937056f 100755
--- a/admin/sql/sqlite/region_group.sql
+++ b/admin/sql/sqlite/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/sqlite/return.sql b/admin/sql/sqlite/return.sql
index ddfbf57..97abd34 100755
--- a/admin/sql/sqlite/return.sql
+++ b/admin/sql/sqlite/return.sql
@@ -54,7 +54,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
@@ -74,7 +74,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/sqlite/return_reason.sql b/admin/sql/sqlite/return_reason.sql
index 18978b9..1624d4a 100755
--- a/admin/sql/sqlite/return_reason.sql
+++ b/admin/sql/sqlite/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/sqlite/return_resolution.sql b/admin/sql/sqlite/return_resolution.sql
index 944d206..83f7f22 100755
--- a/admin/sql/sqlite/return_resolution.sql
+++ b/admin/sql/sqlite/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/sqlite/return_status.sql b/admin/sql/sqlite/return_status.sql
index 39d74d4..c8ed13c 100755
--- a/admin/sql/sqlite/return_status.sql
+++ b/admin/sql/sqlite/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/sqlite/role.sql b/admin/sql/sqlite/role.sql
index fa5da55..f07f014 100755
--- a/admin/sql/sqlite/role.sql
+++ b/admin/sql/sqlite/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/sqlite/setting.sql b/admin/sql/sqlite/setting.sql
index 86f6e38..07a0703 100755
--- a/admin/sql/sqlite/setting.sql
+++ b/admin/sql/sqlite/setting.sql
@@ -2,10 +2,10 @@
-- 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,
)
@@ -28,48 +28,43 @@
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 CONFLICT(`site_id`, `namespace`, `key`) DO UPDATE SET `value` = :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
@@ -78,60 +73,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 )
-
- ON DUPLICATE KEY
- UPDATE value = VALUES(value);
+ ( site_id, namespace, `key`, value )
+
+ VALUES ( :site_id, :namespace, :each_key, :each )
+
+ ON CONFLICT("site_id", "namespace", "key") DO UPDATE SET "value" = :each;
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
;
- END
+ END
diff --git a/admin/sql/sqlite/setting_content.sql b/admin/sql/sqlite/setting_content.sql
index 9f1d4fd..d932747 100755
--- a/admin/sql/sqlite/setting_content.sql
+++ b/admin/sql/sqlite/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,47 +52,102 @@
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 )
- ON CONFLICT(`site_id`, `language_id`, `key`) DO UPDATE SET `value` = :value;
+ ON CONFLICT(`site_id`, `language_id`, `namespace`,`key`) DO UPDATE SET `value` = :value;
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
- END
+ @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 CONFLICT(`site_id`, `language_id`,`namespace`, `key`) DO UPDATE SET `value` = :each.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/sqlite/site.sql b/admin/sql/sqlite/site.sql
index 99291e1..93d321d 100755
--- a/admin/sql/sqlite/site.sql
+++ b/admin/sql/sqlite/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
diff --git a/admin/sql/sqlite/stat.sql b/admin/sql/sqlite/stat.sql
index cb0e939..95d1a01 100755
--- a/admin/sql/sqlite/stat.sql
+++ b/admin/sql/sqlite/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/sqlite/stock_status.sql b/admin/sql/sqlite/stock_status.sql
index 0d49741..6e4437a 100755
--- a/admin/sql/sqlite/stock_status.sql
+++ b/admin/sql/sqlite/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/sqlite/subscription.sql b/admin/sql/sqlite/subscription.sql
index bf6004b..952bfeb 100755
--- a/admin/sql/sqlite/subscription.sql
+++ b/admin/sql/sqlite/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/sqlite/subscription_plan.sql b/admin/sql/sqlite/subscription_plan.sql
index ab6ba84..53193e7 100755
--- a/admin/sql/sqlite/subscription_plan.sql
+++ b/admin/sql/sqlite/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/sqlite/subscription_status.sql b/admin/sql/sqlite/subscription_status.sql
index cc5dd82..c2597a0 100755
--- a/admin/sql/sqlite/subscription_status.sql
+++ b/admin/sql/sqlite/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/sqlite/tax_rate.sql b/admin/sql/sqlite/tax_rate.sql
index 2dc96e1..8ab847c 100755
--- a/admin/sql/sqlite/tax_rate.sql
+++ b/admin/sql/sqlite/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/sqlite/tax_rule.sql b/admin/sql/sqlite/tax_rule.sql
index 512501e..9c0c441 100755
--- a/admin/sql/sqlite/tax_rule.sql
+++ b/admin/sql/sqlite/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/sqlite/tax_type.sql b/admin/sql/sqlite/tax_type.sql
index f5bc62e..2be0cc6 100755
--- a/admin/sql/sqlite/tax_type.sql
+++ b/admin/sql/sqlite/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/sqlite/taxonomy.sql b/admin/sql/sqlite/taxonomy.sql
index 54980e4..351c623 100755
--- a/admin/sql/sqlite/taxonomy.sql
+++ b/admin/sql/sqlite/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/sqlite/taxonomy_item.sql b/admin/sql/sqlite/taxonomy_item.sql
index a3537ca..19948c1 100755
--- a/admin/sql/sqlite/taxonomy_item.sql
+++ b/admin/sql/sqlite/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/sqlite/user.sql b/admin/sql/sqlite/user.sql
index 9aca8a3..8522adf 100755
--- a/admin/sql/sqlite/user.sql
+++ b/admin/sql/sqlite/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/sqlite/user_address.sql b/admin/sql/sqlite/user_address.sql
index 6682210..fb26c1f 100755
--- a/admin/sql/sqlite/user_address.sql
+++ b/admin/sql/sqlite/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/sqlite/user_group.sql b/admin/sql/sqlite/user_group.sql
index fc86caa..a5e7c3b 100755
--- a/admin/sql/sqlite/user_group.sql
+++ b/admin/sql/sqlite/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/sqlite/user_wishlist.sql b/admin/sql/sqlite/user_wishlist.sql
index a3ca6f3..689547b 100644
--- a/admin/sql/sqlite/user_wishlist.sql
+++ b/admin/sql/sqlite/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/sqlite/vendor.sql b/admin/sql/sqlite/vendor.sql
index 7a841df..abb7718 100755
--- a/admin/sql/sqlite/vendor.sql
+++ b/admin/sql/sqlite/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/sqlite/voucher.sql b/admin/sql/sqlite/voucher.sql
index 3f80ec8..e3c9a54 100755
--- a/admin/sql/sqlite/voucher.sql
+++ b/admin/sql/sqlite/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/sqlite/weight_type.sql b/admin/sql/sqlite/weight_type.sql
index 3c90856..0b3af25 100755
--- a/admin/sql/sqlite/weight_type.sql
+++ b/admin/sql/sqlite/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