NAME

App::MonM::Store - DBI interface for checkit's data storing

VERSION

Version 1.00

SYNOPSIS

use App::MonM::Store;

my $dbi = new App::MonM::Store(
    dsn => "DBI:mysql:database=monm;host=mysql.example.com",
    user => "username",
    password => "password",
    set => [
        "RaiseError        0",
        "PrintError        0",
        "mysql_enable_utf8 1",
    ],
);
print STDERR $dbi->error if $dbi->error;

DESCRIPTION

DBI interface for checkit's data storing

new

my $dbi = new App::MonM::Store(
    dsn => "DBI:mysql:database=monm;host=mysql.example.com",
    user => "username",
    password => "password",
    set => [
        "RaiseError        0",
        "PrintError        0",
        "mysql_enable_utf8 1",
    ],
);

Creates DBI object

add

$dbi->add(
    name    => "foo",
    type    => "http",
    source  => "http://example.com",
    status  => 1,
    message => "Ok"
) or die $dbi->error;

Add new record on database

clean

$dbi->clean(
    period => 600
) or die $dbi->error;

Delete too old records from database

del

$dbi->del(
    id => 1
) or die $dbi->error;

Delete record from database

dsn

my $dsn = $dbi->dsn;

Returns DSN string of current database connection

error

my $error = $dbi->error;
$dbi->error("Error message");

Gets/sets error string

get

my %info = $dbi->get(
    name    => "foo"
);

Gets information about file from database

Format:

{
    id      => 1,
    time    => 123456789,
    name    => "foo"
    type    => "http",
    source  => "http://example.com"
    status  => 1,
    message => "Ok"
}
id

The Record ID. Autoincremented value!

message

The checking message

name

Name of checkit section

source

Source Name: URL, DSN or command

status

Status of checking: 000-111 as binary notation

Default: 0

time

Time of record insert

Default: time()

type

Type of checkit source: http, dbi, command

Default: http

is_sqlite

print $dbi->is_sqlite ? "Is SQLite" : "Is not SQLite"

Returns true if type of current database is SQLite

getall

my @files = $dbi->getall();

Returns list of all checkit values

Record format of return result: see "get"

set

$dbi->set(
    id      => 1,
    name    => "foo",
    type    => "http",
    source  => "http://example.com",
    status  => 1,
    message => "Ok"
) or die $dbi->error;

Update existing record on database

SEE ALSO

App::MonM, CTK::DBI

AUTHOR

Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/