1 # Copyright (C) 2005 Stanislav Sinyagin
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 # $Id: SrvExport.pm,v 1.1 2010-12-27 00:03:59 ivan Exp $
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
20 # Class for Collector's external storage export data manipulation.
22 package Torrus::SQL::SrvExport;
27 use base 'Torrus::SQL';
31 # The name of the table and columns where the collector export is stored
32 # defaults configured in torrus-config.pl
36 sub sqlInsertStatement
38 return sprintf('INSERT INTO %s (%s,%s,%s,%s,%s) VALUES (?,?,?,?,?)',
42 $columns{'serviceid'},
52 $self->{'sql'}->select({
53 'fields' => [ $columns{'serviceid'} ],
54 'table' => $tableName,
55 'group' => [ $columns{'serviceid'} ],
56 'order' => [ $columns{'serviceid'} ] });
59 while( defined( my $row = $self->{'sql'}->fetchrow_arrayref() ) )
61 push( @{$ret}, $row->[0] );
68 # YYYY-MM-DD for start and end date
69 # returns the reference to the array of hashes for selected entries.
74 my $startdate = shift;
76 my $serviceid = shift;
78 $self->{'sql'}->select({
80 [ $columns{'srv_date'},
84 'table' => $tableName,
85 'where' => [ {$columns{'serviceid'} => $serviceid},
87 {$columns{'srv_date'} => ['>=', $startdate]},
89 {$columns{'srv_date'} => ['<', $enddate]}
92 return $self->fetchall([ 'srv_date', 'srv_time', 'value', 'intvl' ]);
107 # indent-tabs-mode: nil
108 # perl-indent-level: 4