| Egg::Model::DBI - Model to use DBI for Egg. |
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 the Ima::DBI manpage can be used, Ima::DBI is used. As a result, the Apache::DBI manpage 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 => { ....... }, }, ], ],
the Egg::Helper::Model::DBI manpage 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 the Egg::Model::DBI::Base manpage. the Egg::Model::DBI::dbh manpage 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.
the Egg::Release manpage, the Egg::Model manpage, the Egg::Model::DBI::Base manpage, the Egg::Model::DBI::dbh manpage, the Egg::Helper::Model::DBI manpage, DBI, the Ima::DBI manpage, the UNIVERSAL::require manpage,
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.
| Egg::Model::DBI - Model to use DBI for Egg. |