App::MonM::Notifier::Store - monotifier store class
Version 1.01
use App::MonM::Notifier::Store; my $store = new App::MonM::Notifier::Store( dsn => "DBI:mysql:database=monotifier;host=mysql.example.com", user => "username", password => "password", set => [ "RaiseError 0", "PrintError 0", "mysql_enable_utf8 1", ], ); die($store->error) unless $store->status;
This module provides store methods.
CREATE TABLE IF NOT EXISTS `monotifier` ( `id` int(11) NOT NULL COMMENT 'ID', `to` char(255) DEFAULT NULL COMMENT 'Recipient name', `channel` char(255) DEFAULT NULL COMMENT 'Recipient channel', `subject` text COMMENT 'Message subject', `message` text COMMENT 'Message content', `pubdate` int(11) DEFAULT NULL COMMENT 'Date (unixtime) of the publication', `expires` int(11) DEFAULT NULL COMMENT 'Date (unixtime) of the expire', `status` char(32) DEFAULT NULL COMMENT 'Status of transaction', `comment` char(255) DEFAULT NULL COMMENT 'Comment', `errcode` int(11) DEFAULT NULL COMMENT 'Error code', `errmsg` text COMMENT 'Error message', PRIMARY KEY (`id`), KEY `I_ID` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8
my $store = new App::MonM::Notifier::Store( dsn => "DBI:mysql:database=monotifier;host=mysql.example.com", user => "username", password => "password", set => [ "RaiseError 0", "PrintError 0", "mysql_enable_utf8 1", ], );
Creates DBI object
$store->add( to => $user, channel => $ch_name, subject => $subject, message => $message, ) or die($store->error);
Adds new recored
$store->clean or die($store->error);
Delete incorrect records (that are expired, skipped or failed)
$store->del($id) or die($store->error);
Delete record by id
my $dsn = $store->dsn;
Returns DSN string of current database connection
my $error = $store->error;
Returns error message
my $status = $store->error( "Error message" );
Sets error message if argument is provided. This method in "set" context returns status of the operation as status() method.
my %data = $store->get($id);
Returns data from database by id
my @table = $store->getall(); my @table_100 = $store->getall(100);
Returns data from database with limit supporting
my %data = $store->getByName($username, $ch_name);
Returns data from database by username and channel name
print $store->is_sqlite ? "Is SQLite" : "Is not SQLite"
Returns true if type of current database is SQLite
$store->ping ? 'OK' : 'Database session is expired';
Checks the connection to database
$store->setError($id, 102, "Error string") or die($store->error);
Sets error code and error message by id. See App::MonM::Notifier::Const
$store->setStatus($id, JOB_EXPIRED, "Comment") or die($store->error);
Sets new status by id. See App::MonM::Notifier::Const
my $status = $store->status; my $status = $store->status( 1 ); # Sets the status value and returns it
Get/set BOOL status of the operation
$store->truncate or die($store->error);
Delete all records
See Changes file
Changes
See TODO file
TODO
* none noted
CTK::DBI, App::MonM, App::MonM::Notifier
Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>
Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved
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/
LICENSE
To install App::MonM::Notifier, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::MonM::Notifier
CPAN shell
perl -MCPAN -e shell install App::MonM::Notifier
For more information on module installation, please visit the detailed CPAN module installation guide.