| 1 | package WWW::Garden::Design::Database::Mojo; | ||
| 2 | |||
| 3 | use Moo; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | |||
| 8 | use Data::Dumper::Concise; # For Dumper(). | ||
| 9 | |||
| 10 | use Mojo::Collection; | ||
| 11 | |||
| 12 | use Types::Standard qw/Any/; | ||
| 13 | |||
| 14 | has collection => | ||
| 15 | ( | ||
| 16 | is => 'rw', | ||
| 17 | isa => Any, | ||
| 18 | required => 0, | ||
| 19 | ); | ||
| 20 | |||
| 21 | has dbh => | ||
| 22 | ( | ||
| 23 | is => 'rw', | ||
| 24 | isa => Any, | ||
| 25 | required => 0, | ||
| 26 | ); | ||
| 27 | |||
| 28 | our $VERSION = '0.97'; | ||
| 29 | |||
| 30 | # ----------------------------------------------- | ||
| 31 | |||
| 32 | sub BUILD | ||
| 33 | { | ||
| 34 | my($self, $options) = @_; | ||
| 35 | |||
| 36 | $self -> dbh($$options{dbh}); | ||
| 37 | |||
| 38 | } # End of BUILD; | ||
| 39 | |||
| 40 | # -------------------------------------------------- | ||
| 41 | |||
| 42 | sub arrays | ||
| 43 | { | ||
| 44 | my($self, $sql) = @_; | ||
| 45 | |||
| 46 | return $self -> collection(Mojo::Collection -> new($self -> dbh -> selectall_array($sql) ) ); | ||
| 47 | |||
| 48 | } # End of arrays. | ||
| 49 | |||
| 50 | # -------------------------------------------------- | ||
| 51 | |||
| 52 | sub hashes | ||
| 53 | { | ||
| 54 | my($self, $sql, $key) = @_; | ||
| 55 | |||
| 56 | return $self -> collection(Mojo::Collection -> new($self -> dbh -> selectall_hashref($sql, $key) ) ); | ||
| 57 | |||
| 58 | } # End of hashes. | ||
| 59 | |||
| 60 | # -------------------------------------------------- | ||
| 61 | |||
| 62 | 1; | ||
| 63 | |||
| 64 | =pod | ||
| 65 | |||
| 66 | =head1 NAME | ||
| 67 | |||
| 68 | WWW::Garden::Design::Database::Mojo - Manage the 'flowers' database | ||
| 69 | |||
| 70 | head1 Machine-Readable Change Log | ||
| 71 | |||
| 72 | The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>. | ||
| 73 | |||
| 74 | =head1 Version Numbers | ||
| 75 | |||
| 76 | Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions. | ||
| 77 | |||
| 78 | =head1 Repository | ||
| 79 | |||
| 80 | L<https://github.com/ronsavage/WWW-Garden-Design> | ||
| 81 | |||
| 82 | =head1 Support | ||
| 83 | |||
| 84 | Email the author, or log a bug on RT: | ||
| 85 | |||
| 86 | L<https://rt.cpan.org/Public/Dist/Display.html?Name=WWW::Garden::Design>. | ||
| 87 | |||
| 88 | =head1 Author | ||
| 89 | |||
| 90 | L<WWW::Garden::Design> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2014. | ||
| 91 | |||
| 92 | My homepage: L<https://savage.net.au/>. | ||
| 93 | |||
| 94 | =head1 Copyright | ||
| 95 | |||
| 96 | Australian copyright (c) 2018, Ron Savage. | ||
| 97 | |||
| 98 | All Programs of mine are 'OSI Certified Open Source Software'; | ||
| 99 | you can redistribute them and/or modify them under the terms of | ||
| 100 | The Perl License, a copy of which is available at: | ||
| 101 | http://dev.perl.org/licenses/ | ||
| 102 | |||
| 103 | =cut |