Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # MyApp.pl
- my $model = MyApp::Model->new
- ###########################
- # Database initialization #
- ###########################
- app->attr( 'db' => sub { $model->db } ); # Does the connection
- helper 'db' => sub { shift->app->db };
- package MyApp::Model;
- ######################################
- # Returns Database Connection Object #
- ######################################
- sub db {
- my $self = shift;
- $self->{db} = DBIx::Custom->connect(
- dsn => $config->{db}->{dbi_dsn},
- user => $config->{db}->{username},
- password => $config->{db}->{password},
- option => { mysql_enable_utf8 => 1 }
- ) if !$self->{db};
- return $self->{db};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement