line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::TableInfo; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::TableInfo.pm |
11
|
|
|
|
|
|
|
# Description: Provide meta details about SQL tables |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 30/04/2005 Auto generated file |
16
|
|
|
|
|
|
|
# 30/04/2005 Needed for DatabaseObject registry |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
############################################################################### |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
7
|
use Goo::Object; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
23
|
1
|
|
|
1
|
|
5
|
use Goo::Database; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
6
|
use base qw(Goo::Object); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
569
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
############################################################################### |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# new - constructor |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
############################################################################### |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
1
|
|
my ($class, $table) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $this = $class->SUPER::new(); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $query = Goo::Database::execute_sql("describe $table"); |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$this->{columns} = (); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
while (my $row = Goo::Database::get_result_hash($query)) { |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if ($row->{Key} eq "PRI") { $this->{key} = $row->{Field}; } |
|
0
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
push(@{ $this->{columns} }, $row->{Field}); |
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# remember the type of each field |
50
|
0
|
|
|
|
|
|
$this->{ $row->{Field} } = $row->{Type}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return $this; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
############################################################################### |
60
|
|
|
|
|
|
|
# |
61
|
|
|
|
|
|
|
# get_columns - return an array of columns |
62
|
|
|
|
|
|
|
# |
63
|
|
|
|
|
|
|
############################################################################### |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_columns { |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return @{ $this->{columns} }; |
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
############################################################################### |
76
|
|
|
|
|
|
|
# |
77
|
|
|
|
|
|
|
# get_key - return the primary key of a table |
78
|
|
|
|
|
|
|
# |
79
|
|
|
|
|
|
|
############################################################################### |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub get_key { |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return $this->{key}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
############################################################################### |
91
|
|
|
|
|
|
|
# |
92
|
|
|
|
|
|
|
# get_column_type - return a type for the column |
93
|
|
|
|
|
|
|
# |
94
|
|
|
|
|
|
|
############################################################################### |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub get_column_type { |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
0
|
1
|
|
my ($this, $column) = @_; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return $this->{$column}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 NAME |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Goo::TableInfo - Provide meta details about MySQL tables |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SYNOPSIS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
use Goo::TableInfo; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 DESCRIPTION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 METHODS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item new |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
constructor |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item get_columns |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
return an array of columns |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item get_key |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
return the primary key of a table |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item get_column_type |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
return a type for the column |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=back |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SEE ALSO |
149
|
|
|
|
|
|
|
|