line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
use strict; |
2
|
3
|
|
|
3
|
|
307114
|
use warnings; |
|
3
|
|
|
|
|
36
|
|
|
3
|
|
|
|
|
89
|
|
3
|
3
|
|
|
3
|
|
16
|
use utf8; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
77
|
|
4
|
3
|
|
|
3
|
|
1700
|
use Exporter qw/import/; |
|
3
|
|
|
|
|
46
|
|
|
3
|
|
|
|
|
15
|
|
5
|
3
|
|
|
3
|
|
100
|
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
787
|
|
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw/sql_type/; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my ($value_ref, $type) = @_; |
9
|
|
|
|
|
|
|
SQL::Maker::SQLType->new(value_ref => $value_ref, type => $type); |
10
|
9
|
|
|
9
|
0
|
14932
|
} |
11
|
9
|
|
|
|
|
44
|
|
12
|
|
|
|
|
|
|
my $class = shift; |
13
|
|
|
|
|
|
|
my %args = @_==1 ? %{$_[0]} : @_; |
14
|
|
|
|
|
|
|
bless {%args}, $class; |
15
|
9
|
|
|
9
|
0
|
19
|
} |
16
|
9
|
50
|
|
|
|
43
|
|
|
0
|
|
|
|
|
0
|
|
17
|
9
|
|
|
|
|
100
|
|
18
|
|
|
|
|
|
|
my ($self, $supplied_colname, $quote_cb) = @_; |
19
|
|
|
|
|
|
|
my $stmt; |
20
|
1
|
|
|
1
|
0
|
630
|
if (defined $supplied_colname) { |
21
|
1
|
|
|
1
|
0
|
7
|
$stmt = $quote_cb->($supplied_colname) . ' = ?'; |
22
|
|
|
|
|
|
|
} else { |
23
|
|
|
|
|
|
|
$stmt = '?'; |
24
|
3
|
|
|
3
|
0
|
48
|
} |
25
|
3
|
|
|
|
|
5
|
return $stmt; |
26
|
3
|
100
|
|
|
|
10
|
} |
27
|
2
|
|
|
|
|
7
|
|
28
|
|
|
|
|
|
|
my $self = shift; |
29
|
1
|
|
|
|
|
3
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
3
|
|
|
|
|
13
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=for test_synopsis |
35
|
3
|
|
|
3
|
0
|
28
|
my ($dbh); |
36
|
3
|
|
|
|
|
16
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
SQL::Maker::SQLType - SQL Types wrapper |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use SQL::Maker::SQLType qw/sql_type/; |
44
|
|
|
|
|
|
|
use DBI qw/:sql_types/; |
45
|
|
|
|
|
|
|
use SQL::Maker::Select; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $cond = SQL::Maker::Select->new() |
48
|
|
|
|
|
|
|
->add_select('id') |
49
|
|
|
|
|
|
|
->add_from('foo') |
50
|
|
|
|
|
|
|
->add_where(bar => sql_type(\"bar", SQL_VARCHAR)); |
51
|
|
|
|
|
|
|
my @bind = @{$cond->bind()}; |
52
|
|
|
|
|
|
|
my $sth = $dbh->prepare($cond->as_sql); |
53
|
|
|
|
|
|
|
for my $i (1..scalar(@bind)) { |
54
|
|
|
|
|
|
|
$sth->bind_param($i, ${$bind[$i-1]->value_ref}, $bind[$i-1]->type); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
$sth->execute(); |
57
|
|
|
|
|
|
|
print $sth->fetchrow_array(), "\n"; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This is a wrapper class for SQL types. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SEE ALSO |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
L<SQL::Maker::SQLType>, L<http://labs.cybozu.co.jp/blog/kazuho/archives/2007/09/mysql_param_binding.php> |
66
|
|
|
|
|
|
|
|