Browse Source

added getCategories

master
n0m1s 10 years ago
parent
commit
3810b2807f
1 changed files with 23 additions and 0 deletions
  1. +23
    -0
      databaseOperations.php

+ 23
- 0
databaseOperations.php View File

@ -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


Loading…
Cancel
Save