NAME

Egg::Model::DBIC - DBIx::Class for Egg Model.

SYNOPSIS

__PACKAGE__->egg_startup(
  ...
  .....

  MODEL=> [
    [ DBIC => { schema_names => [qw/ MySchema /] } } ],
   ],

  );

# The object of MyApp::Model::DBIC::MySchema is acquired.
my $model= $e->model('MySchema');

# If the transaction is effective.
$model->storage->txn_begin;

# The object of MyApp::Model::DBIC::MySchema::Moniker is acquired.
my $db = $model->resultset('Moniker');
   or
my $db = $e->model('myscema:moniker');

$db->search( ... );

$model->storage->txn_commit;
  or
$model->storage->txn_rollback;

DESCRIPTION

It is MODEL to use DBIx::Class.

Appropriate Schema is generated by using the helper for use.

% perl myapp_helper.pl Model:DBIC MySchema -d dbi:Pg:dbname=dbname -u user -p passwd

/path/to/MyApp/lib/MyApp/Model/DBIC/MySchema is generated with this.

* Please refer to the document of "Egg::Helper::Model::DBIC " for details for helper's use.

And, the setting of following MODEL is added.

MODEL => [ [ DBIC => {} ] ],

All modules under the control of/path/to/MyApp/lib/MyApp are read by this as Schema. * Specification becomes empty HASH.

If the module such as Schema for the test that doesn't want to be read exists together, the name of Schema is specified.

MODEL=> [
  [ DBIC => { schema_names => [qw/ MySchema /] } ],
 ],

Schema can be acquired for the small letter specification.

my $schema = $e->model('myschema');

When the source is acquired, it specifies it by the small letter without fail.

my $source = $e->mode('myschema:source');

When the object is acquired, it only has to operate it DBIx::Class originally.

Please refer to the document of DBIx::Class for details.

CREATE SCHEMA SOURCE

Please note the following respect when you make the Schema file by oneself.

  • The Schema module succeeds to Egg::Model::DBIC::Schema.

    a necessary method for Schema to operate on Egg such as 'config' is added.

    package MyApp::MySchema;
    use strict;
    use warnings;
    ## use base 'DBIx::Class::Schema';
    
    use base qw/Egg::Model::DBIC::Schema/;
    
    __PACKAGE__->config(
      dsn      => 'dbi:Pg:dbname=mydata',
      user     => 'user',
      password => 'passwd',
      );
    
    ...
    .....

SEE ALSO

DBIx::Class, DBIx::Class::Schema, Egg::Model::DBIC::Schema, Egg::Model::DBIC::Moniker, Egg::Helper::Model::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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 57:

L<> starts or ends with whitespace