NAME
Egg::Model::DBIC - DBIx::Class for Egg.
SYNOPSIS
% cd /MYPROJECT_ROOT/bin
% perl myproject_helper.pl M:DBIC MyApp \
> -d dbi:Pg:dbname=dbname \
> -s localhost \
> -i 5432 \
> -u db_user \
> -p db_password
... done.
output path : /MYPROJECT_ROOT/lib/MYPROJECT/Model/DBIC/MyApp*
Configuration.
MODEL=> [ [ DBIC => { schema_names => [qw/ MyApp /] } ] ],
Or
MODEL=> [ [ DBIC => { auto_collect=> 1 } ] ],
Example of code.
# MYPROJECT::Model::DBIC::MyApp is acquired.
my $schema= $e->model('myapp');
# If AutoCommit is turning off.
$schema->storage->txn_begin;
# MYPROJECT::Model::DBIC::MyApp::Moniker is acquired.
my $db= $schema->resultset('Moniker');
or.
my $db= $e->model('myapp:moniker');
$db->search( ... );
$schema->storage->txn_commit;
or.
$schema->storage->rollback;
* Please see the document of DBIx::Class in detail.
DESCRIPTION
This module is a model class for DBIx::Class for Egg.
Please make Schema by first handling the helper for use.
% perl myproject_helper.pl M:DBIC MyDB -d dbi:Pg:dbname=dbname -u user -p passwd
Other modules are generated with this as for '/MYPROJECT/lib/Model/DBIC/MyDB'.
Next, the setting of DBIC is added to the configuration.
MODEL=> [ [ DBIC => { schema_names => [qw/ MyDB /] } ] ],
* The name of Schema made for schema_names is only specified.
MODEL=> [ [ DBIC => { auto_collect => 1 } ] ],
* The module right under '/MYPROJECT/lib/MYPROJECT/Model/DBIC' is considered to be Schema when doing so and it reads by the automatic operation.
The object of Schema is acquired specifying everything by the small letter.
my $schema = $e->model('mydb');
The object of each source delimits by ':' and specifies the name of Schema and the name of the source. * All are small letters.
my $source = $e->model('mydb:source');
It learns from the document of DBIx::Class and it operates it when the object is acquired.
CREATE SOURCE
Be not in DBIx::Class, and when you make the source by hand power Please succeed to Egg::Model::DBIC::Moniker and make it.
* DBIx::Class has been succeeded to in Egg::Model::DBIC::Moniker.
Please refer in the module generated with the helper for the sample.
- setup
-
It is a method for the start preparation that is called from the controller of the project. * Do not call it from the application.
SEE ALSO
DBIx::Class, Egg::Helper::M::DBIC, Egg::Release,
AUTHOR
Masatoshi Mizuno, <lushe@cpan.org>
COPYRIGHT
Copyright (C) 2007 by 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.