-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
78 lines (61 loc) · 1.7 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Mojolicious::Plugin::AnyData
============================
VERSION 1.20
This Mojolicious web framework plugin is intended for two purposes:
1. To provide access to DBD::AnyData instance from a Mojolicious helper;
2. To create wrappers in a plugin instance for the most commonly used
methods of DBD::AnyData.
It allows the test data to be loaded directly from the memory
or separate config files, but not from a database.
Please note, this plugin should be used in development mode only.
You may use it as a test data source without a database connection.
For more information, see DBD::AnyData
-----------------------------
In Mojolicious::Lite
plugin any_data => {
load_data => {
cars => [
['id', 'model'],
[ 1, 'Honda'],
[ 2, 'Lexus'],
],
},
helper => 'db',
};
get '/get-car/:id' => sub {
my $self = shift;
my $id = $self->stash->{id};
my $model = $self->db->selectrow_array(qq{
select model
from cars
where
id = ?
}, undef, $id);
$self->render( text => $car );
};
get '/new-func' => sub {
my $self = shift;
$self->dbh->func('cars_numbers', 'ARRAY', [
['car_number', 'id'],
[ '12456', 1],
[ '34567', 2],
], 'ad_import');
my $cars_data = $self->db->selectrow_hashref(qq{
select
model, car_number
from cars, cars_numbers
where
cars.id = ?
and cars.id = cars_numbers.id
}, undef, 1);
$self->render(text => Dumper $cars_data);
}
===========================
INSTALL
You can install this module, using following commands:
$ perl Makefile.PL
$ make
$ make test
$ sudo make install
Or, directly from CPAN:
$ sudo cpan Mojolicious::Plugin::AnyData