NAME
App::MonM::Store - DBI interface for checkit's data storing
VERSION
Version 1.01
SYNOPSIS
use
App::MonM::Store;
my
$store
= App::MonM::Store->new(
dsn
=>
"DBI:mysql:database=monm;host=mysql.example.com"
,
user
=>
"username"
,
password
=>
"password"
,
set
=> [
"RaiseError 0"
,
"PrintError 0"
,
"mysql_enable_utf8 1"
,
],
);
die
(
$store
->error)
if
$store
->error;
DESCRIPTION
DBI interface for checkit's data storing. This module provides store methods
new
my
$store
= App::MonM::Store->new(
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
$store
->add(
name
=>
"foo"
,
type
=>
"http"
,
status
=> 1,
message
=>
"Ok"
) or
die
$store
->error;
Add new record on database
clean
$store
->clean(
period
=> 600
) or
die
$store
->error;
Delete too old records from database
del
$store
->del(
id
=> 1
) or
die
$store
->error;
Delete record from database
dsn
my
$dsn
=
$store
->dsn;
Returns DSN string of current database connection
error
my
$error
=
$store
->error;
Returns error message
$store
->error(
"Error message"
);
Sets error message if argument is provided.
get
my
%info
=
$store
->get(
name
=>
"foo"
);
Gets information about file from database
Format:
{
id
=> 1,
time
=> 123456789,
name
=>
"foo"
type
=>
"http"
,
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
$store
->is_sqlite ?
"Is SQLite"
:
"Is not SQLite"
Returns true if type of current database is SQLite
getall
my
@files
=
$store
->getall();
Returns list of all checkit values
Record format of return result: see "get"
ping
$store
->ping ?
'OK'
:
'Database session is expired'
;
Checks the connection to database
set
$store
->set(
id
=> 1,
name
=>
"foo"
,
type
=>
"http"
,
status
=> 1,
message
=>
"Ok"
) or
die
$store
->error;
Update existing record on database
SEE ALSO
AUTHOR
Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>
COPYRIGHT
Copyright (C) 1998-2022 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/