Egg::Model::DBI - Model to use DBI for Egg.
my $dbh= $e->model('dbi::main'); # Or, if Egg::Model::DBI is default. my $dbh= $e->model; my $sth= $dbh->prepare( ........ ); $dbh->do('......', undef, ....); $dbh->disconnect;
It is a model component to use DBI.
If Ima::DBI can be used, Ima::DBI is used. As a result, Apache::DBI is not needed for the perpetuity connection environment.
Two or more connection destination can be treated at the same time.
To use it, 'DBI' is added to the MODEL setting of the configuration of the project.
% vi /path/to/MyApp/lib/MyApp/config.pm .............. ..... MODEL=> [ [ DBI => { dns => 'dbi: ......... ', user => '...', password => '...', options => { ....... }, }, ], ],
Egg::Helper::Model::DBI when there is two or more connection destination The component module that is used and this model uses is made under the control of the project.
# Generation of component module. % cd /path/to/MyApp/bin % ./myapp_helper M::Model [CONNECTION_NAME] -d ... -u ... -p ...
The parameter passed to DBI in the generated module is set.
% vi /path/to/MyApp/lib/MyApp/Modle/DBI/[CONNECTION_NAME].pm ........... ..... __PACKAGE__->config( default => 0, dsn => 'dbi: ......', user => '......', password => '......', options => { AutoCommit => 1, RaiseError => 1, PrintError => 0, }, );
And, 'DBI' is added to the configuration.
% vi /path/to/MyApp/lib/MyApp/config.pm ......... ... MODEL=> ['DBI'],
The data base handler at the connection destination returns only by calling $e->model if the connection destination always becomes default, this model defaults, and it operates when the connection destination is only one.
my $dbh= $e->model;
The data base handler at the connection to which 'default' is effective in the component module destination returns by default when two or more connection destination has been treated.
If 'default' of all components is invalid, it defaults to the component sorted most first and it treats.
DSN passed to DBI module.
Data base user who passes it to DBI module.
Data base password passed to DBI module.
Option to pass to DBI module.
An undefined option item is buried by the default of this module. Especially, default makes the transaction of PostgreSQL and Oracle effective. It is options and AutoCommit? to invalidate this. It is necessary to describe clearly.
options => { AutoCommit => 1 },
The following settings are done in default.
When Ima::DBI is effective.
FetchHashKeyName? = 1 And, it defaults about Ima::DBI.
When Ima::DBI is invalid.
RaiseError = 1 PrintError = 0 Taint = 1 ChopBlanks = 1 ShowErrorStatement = 1 FetchHashKeyName = 1
This module only does manager operation.
The document that relates to the data base handler is Egg::Model::DBI::Base. Egg::Model::DBI::dbh Please drink and refer to Cata.
The list of the data base handler that has been called is returned by the HASH reference. Please note that the call order is not secured.
if (my $handlers= $dbi->handlers) { while (my($label, $obj)= each %$handlers) { ........ .... } }
Constructor.
When $e->model('dbi') and the label are described clearly and called, the object is restored from this constructor.
my $dbi= $e->model('dbi');
The acquired data base handler is done in the handlers method and all disconnect is done.
Egg::Release, Egg::Model, Egg::Model::DBI::Base, Egg::Model::DBI::dbh, Egg::Helper::Model::DBI, DBI, Ima::DBI, UNIVERSAL::require,
Masatoshi Mizuno, <lushe@cpan.org>
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.
To install Egg::Release::DBI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Egg::Release::DBI
CPAN shell
perl -MCPAN -e shell install Egg::Release::DBI
For more information on module installation, please visit the detailed CPAN module installation guide.