Kazunori Minoda > Class-orMapper-0.05 > Class::orMapper

Download:
Class-orMapper-0.05.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.05   Source   Latest Release: Class-orMapper-0.06

NAME ^

orMapper - DBI base easy O/R Mapper.

SYNOPSIS ^

 use Class::orMapper;
 my $read_database = {
    dsn => 'dbi:xxxx:dbname=xxxx;host=localhost;port=xxxx',
    uid => 'xxxx',
    pwd => 'xxxx',
    opt => {AutoCommit => 0},
 };
 my $write_database = {
    dsn => 'dbi:xxxx:dbname=xxxx;host=localhost;port=xxxx',
    uid => 'xxxx',
    pwd => 'xxxx',
    opt => {AutoCommit => 0},
 };
 my $db = new Class::orMapper($read_database, $write_database);
 my $data = $db->select_arrayref({
        table => 'xxxx',
        columns => [qw/aaa bbb ccc/],
        where => [
                {aaa => {'=' => 'dddd'}},
        ],
        order => {'bbb' => 'desc'},
 });
 use Data::Dumper;
 warn Dumper($data);

DESCRIPTION ^

This Module is easy database operation module.

Usage ^

 my $data = $db->select_n_arrayref($sql,$value); # $data is Array Reference.
 my $data = $db->select_n_hashref($sql,$value);  # $data is Hash Reference.

 $sql  : SQL(Strings)
 $value: Bind variable with Array Reference.
 ex.) my $sql = "select * from test where hoge=?";
      my $value = [qw/abc/];

 my $data = $db->select_arrayref($param);
 my $data = $db->select_hashref($param);

 parameter format:
 $param = {
    table => 'table_name',
    columns => [aaa,bbb,ccc],
    where => [
        {xxx => {'=' => 'value1', '>' => 'value2'}},
        {xxx => [qw/abc def cfg/],
    ],
    order => {'yyy' => 'desc', 'zzz' => 'asc'},
 };

 $db->insert($param);
 
 parameter format:
 $param = {
    table => 'table_name',
    columns => {
        aaa => 'bbb',
        ccc => 'ddd',
        eee => 'fff',
    },
 };

 $db->update($param);

 parameter format:
 $param = {
    table => 'table_name',
    columns => {
        aaa => 'bbb',
        ccc => 'ddd',
        eee => 'fff',
    },
    where => [
        {xxx => {'=' => 'value1', '>' => 'value2'}},
        {xxx => [qw/abc def cfg/],
    ],
 };     

 $db->delete($param);

 parameter format:
 $param = {
    table => 'table_name',
    where => [
        {xxx => {'=' => 'value1', '>' => 'value2'}},
        {xxx => [qw/abc def cfg/],
    ],
 };

 $db->truncate($param);

 parameter format:
 $param = {
    table => 'table_name',
 };

Copyright ^

Kazunori Minoda (c)2012

syntax highlighting: