-
Notifications
You must be signed in to change notification settings - Fork 7
/
README
92 lines (70 loc) · 2.24 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
DBIx::Custom
DBIx::Custom is Perl module to execute insert, update, delete, and
select easily.
EXAMPLE
use DBIx::Custom;
# Connect
my $dbi = DBIx::Custom->connect(
"dbi:mysql:database=dbname",
'ken',
'!LFKD%$&',
{mysql_enable_utf8 => 1}
);
# Create model
$dbi->create_model('book');
# Insert
$dbi->model('book')->insert({title => 'Perl', author => 'Ken'});
# Update
$dbi->model('book')->update({title => 'Perl', author => 'Ken'}, where => {id => 5});
# Delete
$dbi->model('book')->delete(where => {author => 'Ken'});
# Select
my $result = $dbi->model('book')->select(['title', 'author'], where => {author => 'Ken'});
# Select, more complex
# select book.title as book.title,
# book.author as book.author,
# comnapy.name as company.name
# form book
# left outer join company on book.company_id = company.id
# where book.author = ?
# order by id limit 0, 5
my $result = $dbi->model('book')->select(
[
{book => [qw/title author/]},
{company => ['name']}
],
where => {'book.author' => 'Ken'},
join => ['left outer join company on book.company_id = company.id'],
append => 'order by id limit 0, 5'
);
# Get all rows or only one row
my $rows = $result->all;
my $row = $result->one;
# Execute SQL with named place holder
my $result = $dbi->execute(
"select id from book where author = :author and title like :title",
{author => 'ken', title => '%Perl%'}
);
INSTALLATION
cpan DBIx::Custom
FEATURES
- Execute insert, update, delete, or select statement easily
- Create where clause flexibly
- Named place holder support
- Model support
- Connection manager support
- Choice your favorite relational database management system, MySQL,
SQLite, PostgreSQL, Oracle, Microsoft SQL Srver, Microsoft Access,
or anything,
- Filtering by data type or column name
- Create order by clause flexibly
DOCUMENTS
DBIx::Custom Documents
https://github.com/yuki-kimoto/DBIx-Custom/wiki
API reference
http://search.cpan.org/~kimoto/DBIx-Custom/
CPAN
http://search.cpan.org/~kimoto/DBIx-Custom/lib/DBIx/Custom.pm
WEB SITE
DBIx::Custom - Perl O/R Mapper
http://dbix-custom.hateblo.jp/