14 Jul 2008 13:32:26 UTC
- Distribution: Egg-Release-DBIC
- Module version: 0.01
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (5 / 0 / 1)
- KwaliteeBus factor: 0
- % Coverage
- License: perl_5
- Activity24 month
- Download (27.15KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionLUSHE Masatoshi Mizunoand 1 contributors
- Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
- SEE ALSO
- COPYRIGHT AND LICENSE
Egg::Plugin::DBIC - Plugin for Egg::Model::DBIC.
use Egg qw/ DBIC /; # $e->model('dbic::myschema'); my $schema= $e->schema_myschema; # $e->model('dbic::myschema::hogetable'); my $table= $e->schema_myschema->resultset('HogeTable'); # The data base handler is acquired beginning the transaction. # If AutoCommit is effective, the transaction is not done. my $dbh= $e->dbh('myschema'); or my $dbh= $e->begin_myschema; # Committing and rollback. # If AutoCommit is effective, nothing is done. $e->commit_myschema; or $e->rollback_myschema; # Delay committing or rollback. # It settles at the end of processing and the transaction is shut. $e->commit_ok( myschema => 1 ); or $e->rollback_ok( myschema => 1 );
It is a plugin that conveniently makes Egg::Model::DBIC available only a little.
The controller is made the setup of Egg::Model::DBIC to use it, and for this plugin to be read.
use Egg qw/ ............. DBIC /;
This plugin adds a concerned some methods to Schema set up with Egg::Model::DBIC to the project.
The data base handler is returned.
LABEL_NAME is a label name to call Schema. The part of first 'dbic::' of the label name is omissible.
my $schema= $e->dbh('myschema');
When LABEL_NAME is omitted, all the data base handlers that Egg::Model::DBIC reads are returned by the list.
my @schema= $e->dbh;
If the transaction is effective, the transaction is begun at the same time.
The function is the same as 'dbh' method.
Because here uses the label name of Schema for the method name, it is not necessary to specify the argument.
my $dbh= $e->begin_myschema;
The delay committing is done when the transaction is effective. This is used to settle at the end of processing and to commit it.
LABEL_NAME is a label name to call Schema. It is not omissible.
FLAG_BOOL is a flag whether execute it. When 0 is redefined after it keeps effective, it becomes a cancellation.
# The delay committing is effectively done. $e->commit_ok( myschema => 1 ); # The delay committing is canceled. $e->commit_ok( myschema => 0 );
The delay rollback is done when the transaction is effective. This is used to settle at the end of processing and to do the rollback.
However, this plugin is effective, not effective the delay committing, either always does the rollback by the transaction, and completes processing. Therefore, I think that it will use it by the cancellation usage when the delay committing is effectively done.
Even if the delay committing of same Schema effectively becomes it, it is disregarded when this method is made effective.
# The delay rollback is made effective. $e->rollback_ok( myschema => 1 ); # The delay rollback is invalidated. $e->rollback_ok( myschema => 0 );
The object of the schema is returned.
This is made to be able to write the place usually assumed the $e->model('dbic::myschema') only a little short.
my $schema= $e->schema_myschema;
If the transaction is effective, it immediately commits it.
If the transaction is effective, the rollback is immediately done.
Masatoshi Mizuno <email@example.com>
Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
Module Install Instructions
To install Egg::Release::DBIC, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Egg::Release::DBIC
For more information on module installation, please visit the detailed CPAN module installation guide.