line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::DBI::Loader::Informix; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
55001
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
111
|
|
4
|
|
|
|
|
|
|
require Class::DBI::Informix; |
5
|
|
|
|
|
|
|
require Class::DBI::Loader::Generic; |
6
|
2
|
|
|
2
|
|
12
|
use base qw(Class::DBI::Loader::Generic); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1948
|
|
7
|
2
|
|
|
2
|
|
55076
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
91
|
|
8
|
2
|
|
|
2
|
|
2751
|
use DBI; |
|
2
|
|
|
|
|
19248
|
|
|
2
|
|
|
|
|
104
|
|
9
|
2
|
|
|
2
|
|
15
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
837
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$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 provides a mechanism of automatically setting |
35
|
|
|
|
|
|
|
up the L sub-classes on demand. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This module provides the Informix specific methods required by |
38
|
|
|
|
|
|
|
L. The complete documentation can |
39
|
|
|
|
|
|
|
be found in L |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _db_class |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
0
|
|
|
return 'Class::DBI::Informix'; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _tables |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
51
|
0
|
0
|
|
|
|
|
my $dbh = DBI->connect( @{ $self->{_datasource} } ) or croak($DBI::errstr); |
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
my @tables = map { /([^.]+$)/ and $1 } ($dbh->func('user','_tables')); |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return @tables; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _relationships |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
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(<
|
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()} ) |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
{ |
87
|
|
|
|
|
|
|
eval |
88
|
0
|
|
|
|
|
|
{ |
89
|
0
|
|
|
|
|
|
$self->_has_a_many($table, |
90
|
|
|
|
|
|
|
$fk->[0], |
91
|
|
|
|
|
|
|
$fk->[1]); |
92
|
|
|
|
|
|
|
}; |
93
|
0
|
0
|
0
|
|
|
|
warn qq/\# has_a_many failed "$@"\n\n/ if $@ && $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, L |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Jonathan Stowe |
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
|
|
|
|
|
|
|
1; |