From a2dd6ddf83ba343e4e06748df07b7597761eb02f Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Sun, 10 Nov 2019 16:04:24 +0100 Subject: [PATCH] fixed very ugly and ambiguous sql select on products --- assets/php/utils.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/assets/php/utils.php b/assets/php/utils.php index 874ba6a..dca61ef 100644 --- a/assets/php/utils.php +++ b/assets/php/utils.php @@ -41,7 +41,8 @@ function connect_user($user_id, $long_expiration = true) $query->bindValue(":user_id", $user_id); $query->bindValue( ":connection_eol", - date('Y-m-d H:i:s', strtotime("now + $delay seconds")), PDO::PARAM_STR + date('Y-m-d H:i:s', strtotime("now + $delay seconds")), + PDO::PARAM_STR ); $query->bindValue(":session_id", $session_id); @@ -276,8 +277,13 @@ function get_users_products_array() $user_products = array(); $sql = "SELECT - id, name, description, expiration_date, added_date, cupboard_name, public_id - FROM products WHERE owner_id = :owner_id;"; + products.id AS id, products.name AS name, products.description AS description, + cupboards.id AS cupboard_id, cupboards.name AS cupboard_name, + cupboards.description AS cupboard_description, expiration_date, + added_date + FROM products + INNER JOIN cupboards ON products.cupboard_id = cupboards.id + WHERE products.owner_id = :owner_id;"; $query = $PDO->prepare($sql); $query->bindValue(":owner_id", get_user_info_from_session_id("id"));