-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder_insert.sql
More file actions
21 lines (18 loc) · 813 Bytes
/
Copy pathorder_insert.sql
File metadata and controls
21 lines (18 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
SELECT 'redirect' AS component,
'signin.sql?error' AS link
WHERE NOT EXISTS (SELECT 1 FROM login_session WHERE id=sqlpage.cookie('session'));
SET group_id = (SELECT user_info.groupe FROM login_session join user_info on user_info.username=login_session.username WHERE id = sqlpage.cookie('session'));
INSERT INTO orders(customer_name, customer_mode)
VALUES (:Name, :paiement);
INSERT INTO order_items(order_id, quantity, product_id, remise)
SELECT
last_insert_rowid(),
CAST(quantity.value AS INTEGER),
CAST(product.value AS INTEGER),
coalesce(:remise,0)
FROM JSON_EACH(:product_quantity) quantity
INNER JOIN JSON_EACH(:product_id) product USING (key)
WHERE CAST(quantity.value AS INTEGER) > 0
RETURNING
'order.sql?id=' || order_id || '&tab=3' as link,
'redirect' as component;