NAME

Catalyst::Model::DBIS - DBIx:Simple Model Class

SYNOPSIS

$c->model('DBIS')->insert('test_log_db', {
    user_agent      => $c->req->user_agent,
    insert_datetime => ['NOW()'],
});

$c->stash->{users} = $c->model('DBIS')->select(
    'tickets', '*', {
        status => $c->req->param('status') || 0,
    },
)->hashes;

$c->model('DBIS')->query('SELECT 1 + 1')->into( $c->stash->{answer} );

DESCRIPTION

This is the DBIx::Simple model class. DBIx::Simple is smart. I think this model is good for the beginner. But of course you know, If you want more wise and more smart one, Catalyst::Model::DBIC::Schema is recommended.

CREATE APP MODEL CLASS

Using helper...(see Catalyst::Helper::Model::DBIS)

% ./script/myapp_create.pl model DBIS DBIS dsn user password

Or manually create in lib/MyApp/Model/DBIS.pm

package MyApp::Model::DBIS;
use strict;
use base 'Catalyst::Model::DBIS';

__PACKAGE__->config(
    connect_info => [ 
        'dbi:mysql:myapp_db', 
        'myapp_user', 
        'myapp_pass', 
        { RaiseError => 1 },
        { on_connect_do => [ 'set names utf8' ] },
    ],
);

1;

CONFIGS

In lib/MyApp/Model/DBIS.pm as above, or in myapp.yaml file like this.

Model::DBIS:
connect_info:
    - dbi:SQLite:dbname=myapp.db

connect_info

List of arguments to DBI-connect()>. See DBI for more description.

DBIC's on_connect_do support

This module emulates DBIx::Class's on_connect_do feature. connect_info can take a hash at the end.

AUTHOR

Naoki Tomita <tomita@e8y.net>

LICENSE

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

SEE ALSO

Catalyst::Helper::Model::DBIS, DBIx::Simple