Catalyst::Model::DBIxResultSet - A Catalyst model for DBIx::ResultSet.
Create a model in you Catalyst apps Model directory:
package MyApp::Model::DBIxResultSet; use Moose; use namespace::autoclean; extends 'Catalyst::Model::DBIxResultSet'; __PACKAGE__->config( dsn => ..., username => ..., password => ..., attr => { ... }, ); __PACKAGE__->meta->make_immutable; 1;
Instead of setting the dsn, etc, you can pass a pre-initialized DBIx::ResultSet::Connector object:
__PACKAGE__->config( connector => $my_connector, );
Then in your controllers:
my $model = $c->model('DBIxResultSet'); my $rs = $model->resultset('users'); $c->stash->{users} = $rs->array_of_hash_rows();
This class is a Catalyst Model that wraps around DBIx::ResultSet.
All attributes are typically set using the __PACKAGE__->config() paradigm as outlined in the "SYNOPSIS".
The DSN for connecting to a database. See DBI for more information on what DSNs look like. This attribute it required unless you directly set the "connector" attribute.
The username to access your database with.
The password to access your database with.
A hash ref of attributes. See DBI for valid attributes.
The DBIx::ResultSet::Connector object. This defaults to a new connector using the dsn, username, password, and attr attributes.
my $users = $model->resultset('users');
See "resultset" in DBIx::ResultSet::Connector.
my $date_time = $model->format_datetime( DateTime->now() );
See "format_datetime" in DBIx::ResultSet::Connector.
my $date = $model->format_date( DateTime->now() );
See "format_date" in DBIx::ResultSet::Connector.
my $time = $model->format_time( DateTime->now() );
See "format_time" in DBIx::ResultSet::Connector.
Aran Clary Deltac <bluefeet@gmail.com>
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Catalyst::Model::DBIxResultSet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Model::DBIxResultSet
CPAN shell
perl -MCPAN -e shell install Catalyst::Model::DBIxResultSet
For more information on module installation, please visit the detailed CPAN module installation guide.