NAME

Catalyst::Model::DBIx::Raw - A Catalyst Model for DBIx::Raw

VERSION

version 0.006

SYNOPSIS

   # Use the helper to add a DBIx::Raw model to your application
   script/myapp_create.pl model Raw DBIx::Raw

   package YourApp::Model::Raw;
   use parent 'Catalyst::Model::DBIx::Raw';

   __PACKAGE__->config(
       dsn => 'dsn',
       user => 'user',
       password => 'password',
   );

   #or
   __PACKAGE__->config(
       conf => '/path/to/conf.pl',
   );

   #or
   __PACKAGE__->config(
       dbix_class_model => 'DB', #will use same dbh as DBIx::Class if you have a DBIx::Class model named 'DB'
   );


   1;
   
   package YourApp::Controller::Foo;

   sub index : Path('/') {
       my ($self, $c) = @_;
       my $name = $c->model('Raw')->raw("SELECT name FROM people WHERE id=1");
       $c->res->body("Hello, $name!");
   }

   1;

METHODS

new

Catalyst calls this method.

CONFIG

Catalyst::Model::DBIx::Raw takes in all of the same options as config options that DBIx::Raw accepts for new. You can use dsn, user, and password to connect:

__PACKAGE__->config(
    dsn => 'dsn',
    user => 'user',
    password => 'password',
);

Or you can use a conf file:

__PACKAGE__->config(
    conf => '/path/to/conf.pl',
);

See DBIx::Raw for more information on those options. Additionally, there is one new option in Catalyst::Model::DBIx::Raw, and that is dbix_class_model:

__PACKAGE__->config(
    dbix_class_model => 'DB', 
);

This is the name of your DBIx::Class model, if you have one. If passed in, Catalyst::Model::DBIx::Raw will reuse the same dbh that DBIx::Class is using. This can be useful if you have DBIx::Class being used for things such as session management or CRUD with forms, but you are using Catalyst::Model::DBIx::Raw to query yourself. This way you do not unecessarily create two database handles. Even if you do not use DBIx::Class in a particular call, Catalyst::Model::DBIx::Raw can still use the DBIx::Class model to get a database handle.

NOTES

One thing to note is that Catalyst::Model::DBIx::Raw uses the same DBIx::Raw object every request, but gets a new dbh every request using DBIx::Raw's connect method.

AUTHOR

Adam Hopkins <srchulo@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Adam Hopkins.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.