From 7dd04a84ab530ef572df3b0df4fa444271f78c7e Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 3 Feb 2020 10:22:56 +0100 Subject: Add ability to see description on list.php --- db.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'db.php') diff --git a/db.php b/db.php index 0f0c2d7..97a5c91 100644 --- a/db.php +++ b/db.php @@ -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; -- cgit v1.2.3