diff options
author | Camil Staps | 2020-02-03 10:22:56 +0100 |
---|---|---|
committer | Camil Staps | 2020-02-03 10:22:56 +0100 |
commit | 7dd04a84ab530ef572df3b0df4fa444271f78c7e (patch) | |
tree | 7b9be02b61277aeb910a3a0bb69eb32e2141b1a8 /db.php | |
parent | Initial commit (diff) |
Add ability to see description on list.php
Diffstat (limited to 'db.php')
-rw-r--r-- | db.php | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -31,6 +31,31 @@ function add_event ($info) return $id; } +function get_event ($id) +{ + global $pdo; + $st=$pdo->prepare ( + 'select `title`,`location`,`start_date`,`end_date`,`description`,`sources`.`source` ' . + 'from `events` inner join `sources` on `events`.`source`=`sources`.`id` ' . + 'where `events`.`id`=?' + ); + if (!$st->execute ([$id])){ + $err=$st->errorInfo(); + throw new Exception ('Error ('.$err[0].', '.$err[1].'): '.$err[2]); + } + $event=$st->fetch (PDO::FETCH_ASSOC); + + $st=$pdo->prepare ( + 'select `keywords`.`keyword` from `keywords` ' . + 'where exists (select * from `event_keyword` where `event`=? and `event_keyword`.`keyword`=`keywords`.`id`)' + ); + $st->execute ([$id]); + $keywords=$st->fetchAll (PDO::FETCH_NUM); + $event['keywords']=array_map ('array_shift',$keywords); + + return $event; +} + function get_events ($keywords=[]) { global $pdo; |