line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cosmic::DB::SQL; |
2
|
3
|
|
|
3
|
|
799
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
93
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
74
|
|
4
|
3
|
|
|
3
|
|
15
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1087
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=pod |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Master Cosmic::DB::SQL object class, used to retain info and spawn new Cosmic::DB::SQL::Generic derived objects. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
1
|
|
|
1
|
0
|
849
|
my $class = shift; |
14
|
1
|
|
|
|
|
3
|
my ( $dbh ) = @_; |
15
|
1
|
50
|
|
|
|
5
|
croak( 'No database handle passed' ) unless ref( $dbh ) eq 'DBI::db'; |
16
|
1
|
|
|
|
|
5
|
my $self = bless { dbh => $dbh }, $class; |
17
|
1
|
|
|
|
|
9
|
return $self; |
18
|
|
|
|
|
|
|
}#sub |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=item |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Factory for Cosmic::DB::SQL::Generic derived objects. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub sql { |
27
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
28
|
0
|
|
|
|
|
|
my $SQL; |
29
|
0
|
0
|
0
|
|
|
|
if ( $self->{dbh}->{Driver}->{Name} eq 'mysql' || $self->{dbh}->{Driver}->{Name} eq 'mysqlPP' ) { |
30
|
0
|
|
|
|
|
|
require Cosmic::DB::SQL::MySQL; |
31
|
0
|
|
|
|
|
|
return Cosmic::DB::SQL::MySQL->new( $self->{dbh} ); |
32
|
|
|
|
|
|
|
}#if |
33
|
0
|
0
|
|
|
|
|
if ( $self->{dbh}->{Driver}->{Name} eq 'Pg' ) { |
34
|
0
|
|
|
|
|
|
require Cosmic::DB::SQL::Postgres; |
35
|
0
|
|
|
|
|
|
return new Cosmic::DB::SQL::Postgres( $self->{dbh} ); |
36
|
|
|
|
|
|
|
}#if |
37
|
0
|
0
|
|
|
|
|
if ( $self->{dbh}->{Driver}->{Name} eq 'Oracle' ) { |
38
|
0
|
|
|
|
|
|
require Cosmic::DB::SQL::Oracle; |
39
|
0
|
|
|
|
|
|
return new Cosmic::DB::SQL::Oracle( $self->{dbh} ); |
40
|
|
|
|
|
|
|
}#if |
41
|
0
|
0
|
|
|
|
|
if ( $self->{dbh}->{Driver}->{Name} eq 'ODBC' ) { |
42
|
|
|
|
|
|
|
# TODO extra ODBC check for SQL Server |
43
|
0
|
|
|
|
|
|
require Cosmic::DB::SQL::SQLServer; |
44
|
0
|
|
|
|
|
|
return new Cosmic::DB::SQL::SQLServer( $self->{dbh} ); |
45
|
|
|
|
|
|
|
}#if |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
croak( "DB $self->{dbh}->{Driver}->{Name} not supported" ); |
48
|
|
|
|
|
|
|
}#sql |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |