fixed very ugly and ambiguous sql select on products

This commit is contained in:
Louis Vallat 2019-11-10 16:04:24 +01:00
parent 8d6fcfd4ec
commit a2dd6ddf83

View File

@ -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"));