From 978a1651bac3faf5e91ddba327bf39aeb6a4cb63 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:28:59 +0200 Subject: Adding upstream version 0.10.0. Signed-off-by: Daniel Baumann --- library/Reporting/Database.php | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 library/Reporting/Database.php (limited to 'library/Reporting/Database.php') diff --git a/library/Reporting/Database.php b/library/Reporting/Database.php new file mode 100644 index 0000000..3dabe17 --- /dev/null +++ b/library/Reporting/Database.php @@ -0,0 +1,58 @@ +get('backend', 'resource', 'reporting') + )); + + $config->options = [\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_OBJ]; + if ($config->db === 'mysql') { + $config->options[\PDO::MYSQL_ATTR_INIT_COMMAND] = "SET SESSION SQL_MODE='STRICT_TRANS_TABLES" + . ",NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'"; + } + + $conn = new RetryConnection($config); + + return $conn; + } + + protected function listTimeframes() + { + $select = (new Sql\Select()) + ->from('timeframe') + ->columns(['id', 'name']); + + $timeframes = []; + + foreach ($this->getDb()->select($select) as $row) { + $timeframes[$row->id] = $row->name; + } + + return $timeframes; + } + + protected function listTemplates() + { + $select = (new Sql\Select()) + ->from('template') + ->columns(['id', 'name']); + + $templates = []; + + foreach ($this->getDb()->select($select) as $row) { + $templates[$row->id] = $row->name; + } + + return $templates; + } +} -- cgit v1.2.3