#!/usr/bin/perl -w package Conf; use DBI; my $dbh = DBI->connect("DBI:mysql:database=framework;host=192.168.1.1;port=3306;", "test", "test", {'RaiseError' => 1}); sub new { $class = shift; my $self = {}; die "ERROR: Connection to DB failed.Dying." if !$dbh; bless $self, $class; return $self; } sub FetchDataset { my ( $self,$label_id,$role_id,$data_type ) = @_; print "$self\n"; print "$label_id\n"; print "$role_id\n"; print "$data_type\n"; if ($data_type eq "dataset") { $sth = $dbh->prepare(qq{ SELECT `cfg_role_attrs`.`attr_key` , `cfg_datasets`.`attr_value` FROM `cfg_datasets` LEFT JOIN `cfg_role_attrs` ON `cfg_datasets`.`attr_id` = `cfg_role_attrs`.`attr_id` WHERE `cfg_datasets`.`role_id` = $role_id}); $rv = $sth->execute(); if (!$rv) { die "Building 'global' dataset for: |$label_id - $role_id : FAILED\n"; } $self = $sth->fetchrow_hashref(); return $self; } } sub GetValue { my ($key) = @_; return $self->{$key}; } 1;