Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 22. január 2025

Súbor: [Platon] / scripts / perl / accounting / modules / db.pm (stiahnutie)

Revízia 1.1, Tue Mar 15 23:17:56 2005 UTC (19 years, 10 months ago) by rajo

Modules for accounting scripts.

#!/usr/bin/perl -w

#
# modules/db.pm
#
# Developed by Lubomir Host 'rajo' <rajo AT platon.sk>
# Copyright (c) 2005 Platon SDG, http://platon.sk/
# Licensed under terms of GNU General Public License.
# All rights reserved.
#
# Changelog:
# 2005-03-14 - created
#

# $Platon$

package db;

use strict;
use Carp;
use DBI qw(:sql_types);
use vars qw($VERSION @EXPORT $AUTOLOAD);

use base qw( DBI::db DBI::st );

@EXPORT  = qw( );
$VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/);

sub new
{ # {{{
    my $this  = shift;
    my ($config) = @_;

    my $class = ref($this) || $this;
    my $self = {};

    #
    # Connect to DB
    #
    $self = DBI->connect(
        "dbi:" . $config->data_source() .
        ":database=" . $config->database() .
        ";host=" . $config->db_host(), $config->db_user(), $config->db_password())
        or die "Can't connect to " . $config->db_host() . ": $DBI::errstr";
    bless $self, $class;

    $self->{mysql_auto_reconnect} = 1;

    return $self;

} # }}} 

sub check
{ # {{{
    my ($self) = @_;

    my $rv = $self->ping();
    # auto reconnect must be done explicitely, because this flag is reseted after first reconnect
    $self->{mysql_auto_reconnect} = 1;

    # we are reconnected again (probably ;-), check connection again
    $rv += $self->ping();
    $self->{mysql_auto_reconnect} = 1;

    return $rv;
    
} # }}}

1;

__END__

=head1 NAME

db - <<<description of module>>>

=head1 SYNOPSIS

  use db;

  my $xxx = new db;

=head1 DESCRIPTION

The db module allows you ...
<<<your description here>>>

=head2 EXPORT

<<here describe exported methods>>>

=head1 SEE ALSO

=head1 AUTHORS

Lubomir Host 'rajo', <rajo AT platon.sk>

=cut

# vim: ts=4
# vim600: fdm=marker fdl=0 fdc=3


Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok