line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Shakan::Model::DBIxSkinny; |
2
|
1
|
|
|
1
|
|
101561
|
use strict; |
|
1
|
|
|
|
|
28
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
4
|
1
|
|
|
1
|
|
6
|
use Mouse; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
5
|
|
|
|
|
|
|
with 'HTML::Shakan::Role::Model'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub fill { |
8
|
1
|
|
|
1
|
1
|
14
|
my ($self, $row) = @_; |
9
|
1
|
|
|
|
|
12
|
my $columns = $row->get_columns; |
10
|
1
|
|
|
|
|
107
|
while (my ($k, $v) = each %$columns) { |
11
|
2
|
|
|
|
|
20
|
$self->form->fillin_params->{$k} = $v; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub create { |
16
|
1
|
|
|
1
|
1
|
584
|
my ($self, $model, $name) = @_; |
17
|
1
|
|
|
|
|
3
|
my $row = {}; |
18
|
1
|
|
|
|
|
6
|
my $params = $self->form->params(); |
19
|
1
|
|
|
|
|
2
|
for my $column (@{ $model->schema->schema_info->{$name}->{columns} }) { |
|
1
|
|
|
|
|
5
|
|
20
|
2
|
100
|
|
|
|
22
|
next unless exists $params->{$column}; |
21
|
1
|
|
|
|
|
4
|
$row->{$column} = $params->{$column}; |
22
|
|
|
|
|
|
|
} |
23
|
1
|
|
|
|
|
5
|
$model->insert($name => $row); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
1
|
0
|
sub insert { shift->create(@_) } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub update { |
29
|
1
|
|
|
1
|
1
|
573
|
my ($self, $row) = @_; |
30
|
1
|
|
|
|
|
3
|
my $dat = {}; |
31
|
1
|
|
|
|
|
6
|
my $columns = $row->get_columns; |
32
|
1
|
|
|
|
|
65
|
my $params = $self->form->params(); |
33
|
1
|
|
|
|
|
5
|
for my $column (keys %$columns) { |
34
|
2
|
100
|
|
|
|
8
|
next unless exists $params->{$column}; |
35
|
1
|
|
|
|
|
3
|
$dat->{$column} = $params->{$column}; |
36
|
|
|
|
|
|
|
} |
37
|
1
|
|
|
|
|
4
|
$row->update($dat); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
657
|
no Mouse; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
41
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
HTML::Shakan::Model::DBIxSkinny - DBIx::Skinny binding for HTML::Shakan |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SYNOPSIS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# create form object |
51
|
|
|
|
|
|
|
my $form = HTML::Shakan->new( |
52
|
|
|
|
|
|
|
request => CGI->new(), |
53
|
|
|
|
|
|
|
fields => [ |
54
|
|
|
|
|
|
|
TextField( |
55
|
|
|
|
|
|
|
name => 'foo', |
56
|
|
|
|
|
|
|
), |
57
|
|
|
|
|
|
|
], |
58
|
|
|
|
|
|
|
model => HTML::Shakan::Model::DBIxSkinny->new() |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# fillin_form |
62
|
|
|
|
|
|
|
$form->model->fill($row); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# insert |
65
|
|
|
|
|
|
|
$form->model->create($skinny => $table); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# update |
68
|
|
|
|
|
|
|
$form->model->update($row); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This is L<DBIx::Skinny> binding for L<HTML::Shakan>.You can easy to |
73
|
|
|
|
|
|
|
insert/fill/update by L<HTML::Shakan>. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 METHODS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=over 4 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item $form->model->fill($row); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
fill the $row data to form.$row is instance of row class of DBIx::Skinny. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item my $row = $form->model->create($skinny, $table); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
insert form data to $table. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item my $row = $form->model->insert($skinny, $table); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
insert method is synonym of create method. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item $form->model->update($row); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
update $row by form data. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SEE ALSO |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L<DBIx::Skinny>, L<HTML::Shakan> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|