From 3810b2807f35c3fc45975b95a3a10d2ad710c36d Mon Sep 17 00:00:00 2001 From: TheMrNomis Date: Thu, 3 Dec 2015 10:19:50 +0100 Subject: [PATCH] added getCategories --- databaseOperations.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/databaseOperations.php b/databaseOperations.php index ca0e47b..bec526b 100755 --- a/databaseOperations.php +++ b/databaseOperations.php @@ -25,6 +25,29 @@ function connect() } } +/** + * @brief queries all the categories from the dabase + * @param $db: the PDO connection to the database + * @return al list of all the categories (id, name) + */ +function getCategories($db) +{ + try + { + $request = $db->prepare('SELECT id, nom_cat, sous_cat FROM categorie ORDER BY sous_cat ASC'); + $request->execute(); + $result = $request->fetchAll(); + $request->closeCursor(); + return $result; + } + catch(PDOException $e) + { + //NOTE: change $e->getMessage() by an error message before going to production + echo($e->getMessage()); + die(); + } +} + /** * @brief queries all the events from the database * @param $db: the PDO connection to the database