Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
108 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,64 @@ | ||
=encoding utf8 | ||
|
||
=head1 NAME | ||
|
||
Mojolicious::Plugin::DSC - Mojolicious Plugin | ||
Mojolicious::Plugin::DSC - use DBIx::Simple::Class in your application. | ||
|
||
=head1 SYNOPSIS | ||
|
||
#load | ||
# Mojolicious | ||
$self->plugin('DSC', $config); | ||
|
||
# Mojolicious::Lite | ||
plugin 'DSC', $config; | ||
|
||
#use | ||
my $user = $app->dbix->query('SELECT * FROM users WHERE user=?','ivan'); | ||
|
||
#...and if you added My::User to 'load_classes' (see below) | ||
my $user = My::User->query('SELECT * FROM users WHERE user=?','ivan'); | ||
|
||
=head1 DESCRIPTION | ||
|
||
L<Mojolicious::Plugin::DSC> is a L<Mojolicious> plugin. | ||
Mojolicious::Plugin::DSC is a L<Mojolicious> plugin that helps you | ||
use L<DBIx::Simple::Class> in your application. | ||
It also adds a helper (C<$app-E<gt>dbix> by default) which is a DBIx::Simple instance. | ||
|
||
=head1 CONFIGURATION | ||
|
||
You can add all classes from your schema to the configuration | ||
and they will be loaded when the plugin is registered. | ||
The configuration is pretty flexible: | ||
|
||
# in Mojolicious startup() | ||
$self->plugin('DSC', { | ||
driver => 'SQLite', | ||
database =>':memory:', | ||
}); | ||
#or | ||
$self->plugin('DSC', { | ||
driver => 'mysql', | ||
database => 'mydbname', | ||
host => '127.0.0.1', | ||
user => 'myself', | ||
password => 'secret', | ||
onconnect_do => ['SET NAMES UTF8','SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"'], | ||
dbh_attributes => {RaiseError=>0, AutoCommit=>0}, | ||
namespace => 'My', | ||
#will load My::User, My::Content, My::Pages | ||
load_classes =>['User', 'Content', 'Pages'], | ||
#now you can use $app->DBIX instead of $app->dbix | ||
dbix_helper => 'DBIX' | ||
}); | ||
|
||
=head1 LICENSE AND COPYRIGHT | ||
|
||
Copyright 2012 Красимир Беров (Krasimir Berov). | ||
|
||
This program is free software, you can redistribute it and/or modify it under | ||
the terms of the Artistic License version 2.0. | ||
|
||
See http://dev.perl.org/licenses/ for more information. | ||
|
||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters