| 1 | package Class::DBI::Loader::Informix; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | require Class::DBI::Informix; | |||||||||||||||||||||||||||
| 5 | 2 | require Class::DBI::Loader::Generic; | |||||||||||||||||||||||||||
| 6 | 2 | ▶ | use base qw(Class::DBI::Loader::Generic); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use DBI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | $VERSION = '1.4'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | Class::DBI::Loader::Informix - Class::DBI::Loader Informix Implementation. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | use Class::DBI::Loader; | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | my $loader = Class::DBI::Loader->new( | ||||||||||||||||||||||||||||
| 23 | dsn => 'dbi:Informix:stores', | ||||||||||||||||||||||||||||
| 24 | user => 'informix', | ||||||||||||||||||||||||||||
| 25 | password => '', | ||||||||||||||||||||||||||||
| 26 | namespace => 'Stores', | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | my $class = $loader->find_class('customer'); | ||||||||||||||||||||||||||||
| 30 | my $obj = $class->retrieve(1); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | L<Class::DBI::Loader> provides a mechanism of automatically setting | ||||||||||||||||||||||||||||
| 35 | up the L<Class::DBI> sub-classes on demand. | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | This module provides the Informix specific methods required by | ||||||||||||||||||||||||||||
| 38 | L<Class::DBI::Loader::Generic>. The complete documentation can | ||||||||||||||||||||||||||||
| 39 | be found in L<Class::DBI> | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =cut | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub _db_class | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_db_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 45 | 0 | return 'Class::DBI::Informix'; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | sub _tables | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_tables: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 50 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 51 | 0 | ▶ | my $dbh = DBI->connect( @{ $self->{_datasource} } ) or croak($DBI::errstr); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my @tables = map { /([^.]+$)/ and $1 } ($dbh->func('user','_tables')); | ||||||||||||||||||||||||||
|
Condition0%0/3
/([^.]+$)/ && $1
MC/DC0%0/2
/([^.]+$)/ && $1
/([^.]+$)/
$1
Truth table0%0/3
A && B
A= /([^.]+$)/B= $1
| |||||||||||||||||||||||||||||
| 55 | 0 | return @tables; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | sub _relationships | ||||||||||||||||||||||||||||
| 59 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_relationships: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 60 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | foreach my $table ( $self->tables() ) | |||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||
| 64 | 0 | my $dbh = $self->find_class($table)->db_Main(); | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | my $sth = $dbh->prepare(<<SQL); | |||||||||||||||||||||||||||
| 67 | SELECT f.colname, | ||||||||||||||||||||||||||||
| 68 | d.tabname | ||||||||||||||||||||||||||||
| 69 | FROM systables a, | ||||||||||||||||||||||||||||
| 70 | sysconstraints b, | ||||||||||||||||||||||||||||
| 71 | sysreferences c, | ||||||||||||||||||||||||||||
| 72 | systables d, | ||||||||||||||||||||||||||||
| 73 | sysindexes e, | ||||||||||||||||||||||||||||
| 74 | syscolumns f | ||||||||||||||||||||||||||||
| 75 | WHERE b.constrtype = 'R' | ||||||||||||||||||||||||||||
| 76 | AND a.tabid = b.tabid | ||||||||||||||||||||||||||||
| 77 | AND b.constrid = c.constrid | ||||||||||||||||||||||||||||
| 78 | AND c.ptabid = d.tabid | ||||||||||||||||||||||||||||
| 79 | AND a.tabname = ? | ||||||||||||||||||||||||||||
| 80 | AND b.idxname = e.idxname | ||||||||||||||||||||||||||||
| 81 | AND e.part1 = f.colno | ||||||||||||||||||||||||||||
| 82 | AND e.tabid = f.tabid | ||||||||||||||||||||||||||||
| 83 | SQL | ||||||||||||||||||||||||||||
| 84 | 0 | $sth->execute($table); | |||||||||||||||||||||||||||
| 85 | 0 | for my $fk ( @{$sth->fetchall_arrayref()} ) | |||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||
| 87 | eval | ||||||||||||||||||||||||||||
| 88 | 0 | { | |||||||||||||||||||||||||||
| 89 | 0 | $self->_has_a_many($table, | |||||||||||||||||||||||||||
| 90 | $fk->[0], | ||||||||||||||||||||||||||||
| 91 | $fk->[1]); | ||||||||||||||||||||||||||||
| 92 | }; | ||||||||||||||||||||||||||||
| 93 | 0 | ▶ | warn qq/\# has_a_many failed "$@"\n\n/ if $@ && $self->debug; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ and $self->debug
MC/DC0%0/2
$@ and $self->debug
$@
$self->debug
Truth table0%0/3
A and B
A= $@B= $self->debug
| |||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head1 BUGS | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | This has only tested with IDS 9.40.UC2E1 and 10.UC5 and could well be using | ||||||||||||||||||||||||||||
| 101 | specific features of those databases. If reporting a bug please | ||||||||||||||||||||||||||||
| 102 | specify the server version that use are using. | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | All bug reports and patches should be made via RT at: | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | bug-Class-DBI-Loader-Informix@rt.cpan.org | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | That way I'm less likely to ignore them. | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | L<Class::DBI::Loader>, L<Class::DBI::Loader::Generic> | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | Jonathan Stowe <jns@gellyfish.com> | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | This library is free software - it comes with no warranty whatsoever. | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | Copyright (c) 2006 Jonathan Stowe | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | This module can be distributed under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =cut | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 2 | 1; | |||||||||||||||||||||||||||