blib/lib/DBIx/Oro/Driver/MySQL.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 53 SCAR 30.0
CC
4
Cov
0%
new
20.0
BEGIN
2.0
_connect
2.0
CRAP 20.0
1 package DBIx::Oro::Driver::MySQL;
2 use strict;
3 use warnings;
4 use DBIx::Oro;
5 our @ISA;
6 BEGIN { @ISA = 'DBIx::Oro' };
7  
8 use v5.10.1;
9  
10 use Carp qw/carp croak/;
11  
12 sub new {
13 my $class = shift;
14 my %param = @_;
15  
16 # Database is not given
17 unless ($param{database}) {
18 croak 'You have to define a database name';
19 return;
20 };
21  
22 # Bless object with hash
23 my $self = bless \%param, $class;
24  
25 # Create dsn
26 $self->{dsn} = 'DBI:mysql:database=' . $self->{database};
27  
28 # Add host and port optionally
29 foreach (qw/host port/) {
30 $self->{dsn} .= ";$_=" . $self->{$_} if $self->{$_};
31 };
32  
33 foreach (qw/default_file default_group/) {
34 $self->{dsn} .= ";mysql_read_$_=" . $self->{$_} if $self->{$_};
35 };
36  
37 $self;
38 };
39  
40  
41 # Connect to database
42 sub _connect {
43 my $self = shift;
44  
45 # Add MySQL specific details
46 my $dbh = $self->SUPER::_connect(
47 mysql_enable_utf8 => 1,
48 mysql_auto_reconnect => 0
49 );
50  
51 $dbh;
52 };
53  
54  
55 # Database driver
56 sub driver { 'MySQL' };
57  
58  
59 1;
60  
61  
62 __END__