| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Otogiri; | 
| 2 | 10 |  |  | 10 |  | 956163 | use 5.008005; | 
|  | 10 |  |  |  |  | 118 |  | 
| 3 | 10 |  |  | 10 |  | 54 | use strict; | 
|  | 10 |  |  |  |  | 27 |  | 
|  | 10 |  |  |  |  | 209 |  | 
| 4 | 10 |  |  | 10 |  | 70 | use warnings; | 
|  | 10 |  |  |  |  | 18 |  | 
|  | 10 |  |  |  |  | 471 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = "0.19"; | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 10 |  |  | 10 |  | 4341 | use parent 'Exporter'; | 
|  | 10 |  |  |  |  | 2993 |  | 
|  | 10 |  |  |  |  | 56 |  | 
| 9 | 10 |  |  | 10 |  | 5124 | use SQL::QueryMaker; | 
|  | 10 |  |  |  |  | 30064 |  | 
|  | 10 |  |  |  |  | 953 |  | 
| 10 | 10 |  |  | 10 |  | 4389 | use DBIx::Otogiri; | 
|  | 10 |  |  |  |  | 32 |  | 
|  | 10 |  |  |  |  | 1089 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | our @EXPORT = map {"sql_$_"} qw/ | 
| 13 |  |  |  |  |  |  | eq like lt gt le ge | 
| 14 |  |  |  |  |  |  | is_null is_not_null | 
| 15 |  |  |  |  |  |  | between not_between | 
| 16 |  |  |  |  |  |  | in not_in | 
| 17 |  |  |  |  |  |  | and or not | 
| 18 |  |  |  |  |  |  | op raw | 
| 19 |  |  |  |  |  |  | /; | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | sub new { | 
| 22 | 10 |  |  | 10 | 1 | 18736 | my ($class, %opts) = @_; | 
| 23 | 10 |  |  |  |  | 81 | DBIx::Otogiri->new(%opts); | 
| 24 |  |  |  |  |  |  | } | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | 1; | 
| 27 |  |  |  |  |  |  | __END__ | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | =encoding utf-8 | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | =head1 NAME | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | Otogiri - A lightweight medicine for using database | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | use Otogiri; | 
| 38 |  |  |  |  |  |  | my $db = Otogiri->new(connect_info => ['dbi:SQLite:...', '', '']); | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | $db->insert(book => {title => 'mybook1', author => 'me', ...}); | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | my $book_id = $db->last_insert_id; | 
| 43 |  |  |  |  |  |  | my $row = $db->single(book => {id => $book_id}); | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | print 'Title: '. $row->{title}. "\n"; | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | my @rows = $db->select(book => sql_ge(price => 500)); | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | ### or non-strict mode | 
| 50 |  |  |  |  |  |  | my @rows = $db->select(book => {price => {'>=' => 500}}); | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | for my $r (@rows) { | 
| 53 |  |  |  |  |  |  | printf "Title: %s \nPrice: %s yen\n", $r->{title}, $r->{price}; | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | # or using iterator | 
| 57 |  |  |  |  |  |  | my $iter = $db->select(book => {price => {'>=' => 500}}); | 
| 58 |  |  |  |  |  |  | while (my $row = $iter->next) { | 
| 59 |  |  |  |  |  |  | printf "Title: %s \nPrice: %s yen\n", $row->{title}, $row->{price}; | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | $db->update(book => [author => 'oreore'], {author => 'me'}); | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | $db->delete(book => {author => 'me'}); | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | ### using transaction | 
| 67 |  |  |  |  |  |  | do { | 
| 68 |  |  |  |  |  |  | my $txn = $db->txn_scope; | 
| 69 |  |  |  |  |  |  | $db->insert(book => ...); | 
| 70 |  |  |  |  |  |  | $db->insert(store => ...); | 
| 71 |  |  |  |  |  |  | $txn->commit; | 
| 72 |  |  |  |  |  |  | }; | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | Otogiri is a thing that like as ORM. A slogan is "Schema-less, Fat-less". | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | Please see ATTRIBUTES section of L<DBIx::Otogiri> documentation. | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =head1 METHODS | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | =head2 new | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | my $db = Otogiri->new( connect_info => [$dsn, $dbuser, $dbpass] ); | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | Instantiate and connect to db. Then, it returns L<DBIx::Otogiri> object. | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =head1 EXPORT FUNCTIONS | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | Otogiri exports each SQL::QueryMaker::sql_* functions. (ex. sql_ge(), sql_like() and more...) | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | For more information, please see FUNCTIONS section of L<SQL::QueryMaker>'s documentation. | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | =head1 INFORMATION ABOUT INCOMPATIBILITY | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =head2 version 0.11 | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | An insert() method is removed, and it was become a synonym of fast_insert() method. | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | If you want to use previous style insert() method, please try L<Otogiri::Plugin::InsertAndFetch> . | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | =head1 LICENSE | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | Copyright (C) ytnobody. | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or modify | 
| 109 |  |  |  |  |  |  | it under the same terms as Perl itself. | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | =head1 AUTHOR | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | ytnobody E<lt>ytnobody@gmail.comE<gt> | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | L<DBIx::Otogiri> | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | L<DBIx::Sunny> | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | L<SQL::Maker> | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | L<SQL::QueryMaker> | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | =cut | 
| 126 |  |  |  |  |  |  |  |