MPMinus/Store/MySQL.pm untested

filter: Statementstmt 0.0% 0 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 23 SCAR 6.9
CC
1
Cov
0%
new
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package MPMinus::Store::MySQL; # $Id: MySQL.pm 122 2013-05-07 13:05:41Z minus $
2 use strict;
3
4 =head1 NAME
5
6 MPMinus::Store::MySQL - MySQL
7
8 =head1 VERSION
9
10 Version 1.41
11
12 =head1 SYNOPSIS
13
14 use MPMinus::Store::MySQL;
15
16 # MySQL connect
17 my $mysql = new MPMinus::Store::MySQL (
18 -m => $m, # OPTIONAL
19 -host => '192.168.1.1',
20 -database => 'TEST',
21 -user => 'login',
22 -pass => 'password',
23 -attr => {
24 mysql_enable_utf8 => 1,
25 RaiseError => 0,
26 PrintError => 0,
27 },
28 );
29
30 my $dbh = $mysql->connect;
31
32 my $pingstat = $mysql->ping if $mysql;
33
34 # Table select (as array)
35 my @result = $mysql->table($sql, @inargs);
36
37 # Table select (as hash)
38 my %result = $mysql->tableh($key, $sql, @inargs); # $key - primary index field name
39
40 # Record (as array)
41 my @result = $mysql->record($sql, @inargs);
42
43 # Record (as hash)
44 my %result = $mysql->recordh($sql, @inargs);
45
46 # Fiels (as scalar)
47 my $result = $mysql->field($sql, @inargs);
48
49 # SQL/PL-SQL
50 my $sth = $mysql->execute($sql, @inargs);
51 ...
52 $sth->finish;
53
54 =head1 DESCRIPTION
55
56 MySQL Database independent interface for MPMinus on MPMinus::Store::DBI based.
57
58 See L<MPMinus::Store::DBI>
59
60 =head1 EXAMPLE
61
62 use MPMinus::Store::MySQL;
63
64 my $mysql = new MPMinus::Store::MySQL (
65 -host => '192.168.1.1',
66 -name => 'mylocaldb',
67 -user => 'root',
68 -password => 'password',
69 );
70
71 my @table = $mysql->table("select * from tablename where date = ?", "01.01.2000")
72
73 =head1 HISTORY
74
75 =over 8
76
77 =item B<1.00 / 11.04.2007>
78
79 Init version
80
81 =item B<1.10 / 26.03.2008>
82
83 OOP style supported
84
85 =item B<1.20 / 01.04.2008>
86
87 Module movied to global level
88
89 =item B<1.40 / 27.02.2009>
90
91 Module movied to MPMinus level
92
93 =item B<1.41 / Wed Apr 24 14:53:38 2013 MSK>
94
95 General refactoring
96
97 =back
98
99 =head1 SEE ALSO
100
101 L<MPMinus::Store::DBI>, L<CTK::DBI>, L<Apache::DBI>, L<DBI>
102
103 =head1 AUTHOR
104
105 Serz Minus (Lepenkov Sergey) L<http://serzik.ru> E<lt>minus@mail333.comE<gt>
106
107 =head1 COPYRIGHT
108
109 Copyright (C) 1998-2013 D&D Corporation. All Rights Reserved
110
111 =head1 LICENSE
112
113 This program is free software: you can redistribute it and/or modify
114 it under the terms of the GNU General Public License as published by
115 the Free Software Foundation, either version 3 of the License, or
116 (at your option) any later version.
117
118 This program is distributed in the hope that it will be useful,
119 but WITHOUT ANY WARRANTY; without even the implied warranty of
120 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
121 GNU General Public License for more details.
122
123 See C<LICENSE> file
124
125 =cut
126
127 use vars qw($VERSION);
128 $VERSION = 1.41;
129
130 use MPMinus::Store::DBI;
131 use CTK::Util qw/ :API /;
132
133 sub new {
134 my $class = shift;
135 my @in = read_attributes(MPMinus::Store::DBI::ATTR_NAMES,@_);
136 my %args = (
137 -driver => 'mysql',
138 -m => $in[0],
139 -host => $in[2],
140 -name => $in[3],
141 -user => $in[5],
142 -pass => $in[6],
143 -attr => $in[10],
144 );
145 return new MPMinus::Store::DBI(%args);
146 }
147
148 1;