| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MojoX::Mysql::Result; |
|
2
|
5
|
|
|
5
|
|
21
|
use Mojo::Base -base; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
26
|
|
|
3
|
5
|
|
|
5
|
|
586
|
use Mojo::Util qw(dumper); |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
238
|
|
|
4
|
5
|
|
|
5
|
|
31
|
use Mojo::Collection 'c'; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
2321
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub async { |
|
7
|
0
|
|
|
0
|
0
|
|
my ($self,$sth,$dbh,$cb) = @_; |
|
8
|
0
|
|
|
|
|
|
sleep(0.01) until($sth->mysql_async_ready); |
|
9
|
0
|
|
|
|
|
|
my $counter = $sth->mysql_async_result; |
|
10
|
0
|
|
|
|
|
|
my $collection = $self->collection($sth,$cb); |
|
11
|
0
|
|
|
|
|
|
$sth->finish; |
|
12
|
0
|
|
|
|
|
|
$dbh->commit; |
|
13
|
0
|
|
|
|
|
|
$dbh->disconnect; |
|
14
|
0
|
0
|
|
|
|
|
return wantarray ? ($collection,$counter,$sth,$dbh) : $collection; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub collection { |
|
18
|
0
|
|
|
0
|
0
|
|
my ($self,$sth,$cb) = @_; |
|
19
|
0
|
|
|
|
|
|
my $collection = c(); |
|
20
|
0
|
|
|
|
|
|
my $names = $sth->{'NAME'}; |
|
21
|
0
|
|
|
|
|
|
my $types = $sth->{'mysql_type_name'}; |
|
22
|
0
|
|
|
|
|
|
my $nulls = $sth->{'NULLABLE'}; |
|
23
|
0
|
|
|
|
|
|
while (my $ref = $sth->fetch()) { |
|
24
|
0
|
0
|
|
|
|
|
if(ref($names) eq 'ARRAY'){ |
|
25
|
0
|
|
|
|
|
|
my %hash; |
|
26
|
0
|
|
|
|
|
|
my $count_state = -1; |
|
27
|
0
|
|
|
|
|
|
for(@{$names}){ |
|
|
0
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$count_state++; |
|
29
|
0
|
|
|
|
|
|
my $value = $ref->[$count_state]; |
|
30
|
0
|
|
|
|
|
|
my $type = $types->[$count_state]; |
|
31
|
0
|
|
|
|
|
|
my $null = $nulls->[$count_state]; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
0
|
0
|
|
|
|
if($type eq 'tinyint' || $type eq 'smallint' || $type eq 'mediumint' || $type eq 'integer' || $type eq 'bigint'){ |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
34
|
0
|
0
|
0
|
|
|
|
if(!$value && $null){ |
|
35
|
0
|
|
|
|
|
|
$value = undef; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
else{ |
|
38
|
0
|
|
|
|
|
|
$value = int $value; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
else{ |
|
42
|
0
|
0
|
0
|
|
|
|
if(!$value && $null){ |
|
43
|
0
|
|
|
|
|
|
$value = undef; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
else{ |
|
46
|
0
|
|
|
|
|
|
$value =~ s/^\s+|\s+$//g; |
|
47
|
0
|
0
|
|
|
|
|
utf8::decode($value) unless utf8::is_utf8($value); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
} |
|
50
|
0
|
|
|
|
|
|
$hash{$_} = $value; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
0
|
0
|
|
|
|
|
$self->$cb(\%hash) if(ref $cb eq 'CODE'); |
|
53
|
0
|
|
|
|
|
|
push(@{$collection}, \%hash); |
|
|
0
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
} |
|
56
|
0
|
|
|
|
|
|
return $collection; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
|
61
|
|
|
|
|
|
|
|