aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-05-20 09:15:18 +0200
committerKristian Lyngstol <kristian@bohemians.org>2016-05-20 09:15:18 +0200
commit67fe1ffa1a9d4b878bd820d9bfdade74cdc293ad (patch)
tree8e0cbd304421a9a5210e2fb5297e71f6923c7778 /include
parent1202c0524dd8b5ae84c1094be8c2afdb34a5cf70 (diff)
Add first iteration of dbconfig package
Should do a better job of the naming and the actual $dbh maintenance. I'm thinking that including nms::db should contain a $dbh perhaps.
Diffstat (limited to 'include')
-rw-r--r--include/nms/dbconfig.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/nms/dbconfig.pm b/include/nms/dbconfig.pm
new file mode 100644
index 0000000..b67c040
--- /dev/null
+++ b/include/nms/dbconfig.pm
@@ -0,0 +1,29 @@
+# vim:ts=8:sw=8
+use strict;
+use warnings;
+use utf8;
+use DBI;
+use Data::Dumper;
+use JSON;
+use nms;
+package nms::dbconfig;
+
+use base 'Exporter';
+our @EXPORT = qw(%config);
+our %config;
+my $dbh;
+
+use Data::Dumper;
+
+
+BEGIN {
+ $dbh = nms::db_connect();
+ my $q2 = $dbh->prepare('select * from config order by id desc limit 1;');
+ $q2->execute();
+ while (my $ref = $q2->fetchrow_hashref()) {
+ %config = %$ref;
+ $config{'data'} = JSON::XS::decode_json($ref->{'data'});
+ }
+ $dbh->disconnect();
+}
+1;