From 3655883c9fdafe07ceb901621a85e37cb39b7ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20=C3=85ne?= Date: Thu, 18 Aug 2016 23:17:24 +0200 Subject: [PATCH] Write database configuration through dev-script. --- .gitignore | 1 + dev.sh | 1 + sql_config_example.php | 5 +++++ src/pvv/side/dbactivity.php | 5 ++--- www/index.php | 14 ++++++++------ 5 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 sql_config_example.php diff --git a/.gitignore b/.gitignore index 9b1dffd..319be8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +sql_config.php *.sqlite diff --git a/dev.sh b/dev.sh index 21963b7..688c477 100755 --- a/dev.sh +++ b/dev.sh @@ -1,3 +1,4 @@ #!/bin/sh which -s sqlite3 && test \! -e pvv.sqlite && sqlite3 pvv.sqlite < pvv.sql +test \! -e sql_config.php && cp sql_config_example.php sql_config.php php -S [::]:1080 -t www/ diff --git a/sql_config_example.php b/sql_config_example.php new file mode 100644 index 0000000..99c13c9 --- /dev/null +++ b/sql_config_example.php @@ -0,0 +1,5 @@ +pdo = new PDO($dsn, $username, $password); - $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + public function __construct(PDO $pdo) { + $this->pdo = $pdo; } public function getNextEventFrom(DateTimeImmutable $date) { diff --git a/www/index.php b/www/index.php index 4cd56ab..a489444 100644 --- a/www/index.php +++ b/www/index.php @@ -1,7 +1,14 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$agenda = new \pvv\side\Agenda([ + new \pvv\side\social\NerdepitsaActivity, + new \pvv\side\social\AnimekveldActivity, + new \pvv\side\DBActivity($pdo), + ]); ?> ?> Programvareverkstedet @@ -44,11 +51,6 @@ date_default_timezone_set('Europe/Oslo'); - getNextDays() as $period => $events) if ($events && $counter1 < 2 && $counter2 < 10) { $counter1++ ?>
  • getStart()->format('Y-m-d'); ?>