aboutsummaryrefslogtreecommitdiff
path: root/db.php
diff options
context:
space:
mode:
Diffstat (limited to 'db.php')
-rw-r--r--db.php25
1 files changed, 25 insertions, 0 deletions
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;