Commit 2a5962bd authored by Stephane Crozat's avatar Stephane Crozat

Ajout des jours de début et de fin des Api, modif des vues, modif du PHP pour utiliser les vues

parent 0879efb0
Backup DB
HTTPS
Gestion d'erreurs DB
Élucidation fonctionnement CAS (cf Mattermost)
......@@ -27,8 +27,8 @@ class DB {
}
function subList($utclogin) {
$sql = "SELECT code, name, year, semester, TO_CHAR(subdate,'DD/MM/YYYY') as subdate
FROM api JOIN subscribe ON api.code=subscribe.api
$sql = "SELECT *
FROM vSubscription
WHERE utclogin='".$utclogin."'";
$st = $this->conn->prepare($sql);
$st->execute();
......@@ -51,10 +51,9 @@ class DB {
}
function apiList($utclogin, $semester, $year) {
$sql = "SELECT code, name
FROM api
WHERE semester='".$semester."' AND year=".$year."
ORDER BY code, name";
$sql = "SELECT *
FROM vApi
WHERE semester='".$semester."' AND year=".$year.";
$st = $this->conn->prepare($sql);
$st->execute();
$res = $st->fetchAll(PDO::FETCH_ASSOC);
......
......@@ -15,6 +15,8 @@ class Api {
name : text
year : year
semester : H|E
dbegin : date
dend : date
}
note right of Api : (name,year,semester) key
......
......@@ -6,9 +6,12 @@ CREATE TABLE api (
name TEXT NOT NULL,
year INTEGER NOT NULL,
semester CHAR(1) NOT NULL,
dbegin DATE NOT NULL,
dend DATE NOT NULL,
CHECK (code>0),
CHECK (year>2018 AND year<2100),
CHECK (semester IN ('H','E')),
CHECK (dbegin<=dend),
UNIQUE (name,year,semester)
);
......@@ -21,16 +24,21 @@ CREATE TABLE subscribe (
/** Test dataset **/
INSERT INTO api VALUES (
1,'Poésie et ingénierie',2019,'H'
1,'Poésie et ingénierie',2019,'H',TO_DATE('20190121','yyyymmdd'),TO_DATE('20190125','yyyymmdd')
);
INSERT INTO api VALUES (
2,'Cloud big data blockchain IA',2019,'H'
2,'Cloud big data blockchain IA',2019,'H',TO_DATE('20190125','yyyymmdd'),TO_DATE('20190131','yyyymmdd')
);
INSERT INTO subscribe VALUES (
'crozatst',1,TO_DATE('20181018','YYYYMMDD')
);
CREATE VIEW vSubscrition AS
SELECT ap.code, ap.name, ap.year, ap.semester, su.subdate, su.utclogin FROM
subscribe su JOIN api ap ON ap.code=su.api
ORDER BY ap.year, ap.semester, su.utclogin, ap.code;
CREATE OR REPLACE VIEW vApi AS
SELECT ap.code, ap.name, ap.year, ap.semester, TO_CHAR(ap.dbegin,'TMDay FMDD TMMonth') AS dbegin, TO_CHAR(ap.dend,'TMDay FMDD TMMonth') AS dend
FROM api ap
ORDER BY ap.year, ap.semester, ap.dbegin, ap.dend, ap.code;
CREATE OR REPLACE VIEW vSubscrition AS
SELECT ap.*, TO_CHAR(su.subdate,'DD/MM/YYYY') AS subdate, su.utclogin
FROM subscribe su JOIN vApi ap ON ap.code=su.api
ORDER BY ap.year, ap.semester, ap.dbegin, ap.dend, ap.code, su.utclogin;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment