GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DBIX::SKINNY::MANUAL::JA::INTRO (3)

.ds Aq ’

NAME

DBIx::Skinny::Manual::JA::Intro - DBIx::SkinnyXXXXXXXXXX

CONTENTS

DESCRIPTION

SkinnyXXXXXXXXXXXXXXXXXXXXX

Please translate and read the person in the sphere in English.

XX

XXSkinnyXMySQLXSQLiteXPostgreSQLXOracleXXXXXXXXXXX

XXDBDXXXXXXXXX DBIx::Skinny::DBD::*XXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXX

    SkinnyXXXXXXXXX

SkinnyXXXXXClassXXXXXXX

XXXProjXXXXXXXXXXSkinnyXXXXX



    package Proj::Model;
    use DBIx::Skinny connect_info => +{
        dsn => dbi:SQLite:,
        username => ,
        password => ,
    };
    1;



XXXXXClassXXXXXXX XXXXXDBIx::SkinnyXuseXXX

use strict;

use warnings;

XXXXXXXXXXXXXX

DBIx::SkinnyXuseXXXXXXXdsnXXDBXXXXXXXXXXXXXXXXXXX

.pmXXXXXXXdsnXXXXXXXXXXXX



    package Proj::Model;
    use DBIx::Skinny;
    1;



DBIx::SkinnyXuseXXXXXXXdsnXXXXXXXClassXXXXXXXX DBXXXXXXXXXX



    Proj::Model->connect_info(....); # connect_infoXXXXX



XXXX



    Proj::Model->connect(....): # connectXXXXXdsnXXXXXXXXXXXX



XXXX



    my $model = Proj::Model->new($connection_info); # XXXXXXXXXXXXXXXXXXXXXXXX



XXXXXXXXXXX

XXXXdbXhandlerXXXXXXXXXXXXXXXXXXXXXXX



    Proj::Model->set_dbh($dbh);



XXXXXset_dbhXhandlerXXXXXXXXXXXXXXXdatabase handlerXXXXXXXXXXXXX

    XXXXXXXXXX

SkinnyXXXXORXXXXXXXXXXXtableXXXXXschemaXXXXXXXXXXXXXX

XXXuserXXXXXXXXX



    package Proj::Model::Schema;
    use DBIx::Skinny::Schema;
   
    install_table user => schema {
        pk id;
        columns qw/
            id guid login_id login_pw name mail created_at updated_at
        /;
    };
    1;



DBIx::Skinny::SchemaXuseXXXSchemaXXXXXXXXXXXmethodXexportXXXXX

XXXXXDBIx::Skinny::SchemaXXuseXXX

use strict;

use warnings;

XXXXXXXXXXXXXX

XXXXXuserXXXXX XXXXXXXXid XXXXXXid/guid/login_id/login_pw/name/mail/created_at/updated_at XXXXXXXXXXXXX

SkinnyXXXXORXXXXXXXXXXXXXXXClassXXXXXXXXXXXX

XXXXXXProj::Model::SchemaXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXX

XXuserXXXXXXXnameXXXXXXXXXXXXXXXXXXXXutf8flagXXXXXXXXXXXXXX



    package Proj::Model::Schema;
    use DBIx::Skinny::Schema;
   
    install_utf8_columns qw/name/;
    install_table user => schema {
        pk id;
        columns qw/
            id guid login_id login_pw name mail created_at updated_at
        /;
    };
    1;



XXXXXinstall_utf8_columnsXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXSkinnyXXXXXXXXXXXXXXXX

SkinnyXXXXXXXXXXXXXXXXXXXXXXXSQLXXXXXX XXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX

XXXXXXXinstall_utf8_columnsXXXXXXXXXXXXXXXXXXX XXXXXSkinnyXXXXXXXXXXXXXXXXXXXXXXX

XXXXuserXXXXXXXXXXXXnameXXXXXXXXXX install_utf8_columnsXnameXXXXXXXXuserXXXXXXXXXXXXnameXXXXutf8flagXXXXXXXXXXXX

inflate/deflateXXXXXXX

SkinnyXXinflate/deflateXXXXXXXXXXXX

userXXXXXXXXXXcreated_at/updated_atXXXXXDateTimeXinflate/deflateXXXXXX



    package Proj::Model::Schema;
    use DBIx::Skinny::Schema;
    use DateTime;
    use DateTime::Format::Strptime;
    use DateTime::Format::MySQL;
    use DateTime::TimeZone;
   
    my $timezone = DateTime::TimeZone->new(name => Asia/Tokyo);
    install_inflate_rule ^.+_at$ => callback {
        inflate {
            my $value = shift;
            my $dt = DateTime::Format::Strptime->new(
                pattern   => %Y-%m-%d %H:%M:%S,
                time_zone => $timezone,
            )->parse_datetime($value);
            return DateTime->from_object( object => $dt );
        };
        deflate {
            my $value = shift;
            return DateTime::Format::MySQL->format_datetime($value);
        };
    };
   
    install_table user => schema {
        pk id;
        columns qw/
            id guid login_id login_pw name mail created_at updated_at
        /;
    };
    1;



XXXXXXXXXXXXX

install_inflate_ruleXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX

install_inflate_ruleXinstall_utf8_columnsXXXSkinnyXXXXXXXXXXXXXXXXX

triggerXXXX

SkinnyXXinsert/update/deleteXXXXXXXXXtriggerXXXHookXXXXXXXXXXX

XXXinsertXXcreated_atXXXXXXXXtriggerXXXXXXXX



    package Proj::Model::Schema;
    use DBIx::Skinny::Schema;
    use DateTime;
   
    install_table user => schema {
        pk id;
        columns qw/
            id guid login_id login_pw name mail created_at updated_at
        /;
        trigger pre_insert => sub {
            my ( $class, $args ) = @_;
            $args->{created_at} ||= DateTime->now;
        };
    };
    1;



XXXXXXXXXXXX

XXXXXXXXXXXXXXXXX

pre_insert / post_insert / pre_update / post_update / pre_delete / post_delete

XXXXX

XXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXHookXXXXXXXXXXXXXXXXXXXXX XXHookXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    new

SkinnyXXXXXXXXXXXXXXXXXXDBXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXDBXXXXXXX



    my $model = Proj::Model->new;
    $model->do();



XXXXXXXXXXXDBXXXXXXX



    Proj::Model->do()



XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

WEBXXXXXXXXDBXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXDBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    connection_info / connect /reconnect / set_dbh

connection_info

connect_infoXXXXXXDBXXXXXXXXXX



    Proj::Model->connection_info({
        dsn      => dbi:mysql:test,
        username => username,
        password => password
        connect_options => +{
            RaiseError => 1,
            PrintError => 0,
            AutoCommit => 1,
        },
    });



connection_infoXXXXXXXXXXXXXXDBXXXXXXXXXXXX

XXXXXXXXXXconnect_optionsXXXXXXXXXXXX XXXX

RaiseError: 1

PrintError: 0

AutoCommit: 1

XDBXXXXXXXX

connect

XXXXDBXXXXXXXXXXconnectXXXXXXXXXXX



    Proj::Model->connect({
        dsn      => dbi:mysql:test,
        username => username,
        password => password
        connect_options => +{
            RaiseError => 1,
            PrintError => 0,
            AutoCommit => 1,
        },
    });



reconnect

XXDBXXXXXXXXXXXDBXXXXXXXXXXXX reconnectXXXXXXXXXXX



    Proj::Model->reconnect({
        dsn      => dbi:mysql:test,
        username => username,
        password => password
        connect_options => +{
            RaiseError => 1,
            PrintError => 0,
            AutoCommit => 1,
        },
    });



reconnectXXXXXXXXXXXXXXXXXXXXXXXdatabase handlerXXXXXXXX

set_dbh

XXdatabase handlerXXXXXXXXXXSkinnyXXXhandlerXXXXXXXX set_dbhXXXXXXXXXXX



    Proj::Model->set_dbh($dbh);



set_dbhXXXXXXXXXXXXXXXXXXXXXXXdatabase handlerXXXXXXXX

    dbh

dbhXXXXXXXXXXXXXXXXdatabase handlerXXXXXXXX



    my $dbh = Proj::Model->dbh;



    do

doXXXXX$dbh->doXXXXXXXXXXXXXXXX



    Proj::Model->do(q{
        CREATE TABLE foo (
            id   INT,
            name TEXT
        )
    });



    insert / create

userXXXXXXXXXXinsertXXXXXXXXXXXXXX



    my $row = Proj::Model->insert(user,{
        name => nekokak,
        mail => nekokak _at_ gmail.com,
    });



insertXXXXXXXXXSkinnyXRowXXXXXXXXXXXX



    print $row->name; # nekokak
    print $row->mail; # nekokak _at_ gmail.com



XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXcreateXXXXXinsertXXXXXXXXXXXXXXXXXXXXXXXOKXX



    my $row = Proj::Model->create(user,{
        name => nekokak,
        mail => nekokak _at_ gmail.com,
    });



    update

userXXXXXXXXXXupdateXXXXXXXXXXXXXX



    Proj::Model->update(user, {name => yappo}, {id => 1})



XXXXhashrefXXXXXXXX XXXXhashrefXXXXXXXXXXXXXXXXXX

XXXRowXXXXXXXupdateXXXXXXXXXXXX



    my $row = Proj::Model->insert(user,{
        name => nekokak,
        mail => nekokak _at_ gmail.com,
    });
    $row->update({name => yappo});



    delete

userXXXXXXXXXXdeleteXXXXXXXXXXXXX



    Proj::Model->delete(user, {id => 1});



hashrefXdeleteXXXXXXXXXXXXXXXXXXXX

XXdeleteXXXXXupdateXXXXXXXXRowXXXXXXXdeleteXXXXXXXXXXXX



    my $row = Proj::Model->insert(user,{
        name => nekokak,
        mail => nekokak _at_ gmail.com,
    });
    $row->delete;



    bulk_insert

userXXXXXXXXXXXinsertXXXXXXXXXXXXXXXXXX



    Proj::Model->bulk_insert(user,
        [
            {
                name => nekokak,
                mail => nekokak _at_ gmail.com,
            },
            {
                name => yappo,
                mail => yappo _at_ example.com,
            },
        ]
    );



bulk_insertXXXXinsertXXXXXXXXXXXXXXXXXXXXXXX

    find_or_create / find_or_insert

userXXXXXXXXXXXXXXXXXXXXXXXXXXselectX XXXXXXXXXXXXinsertXXXXXXXXXXX



    my $row = Proj::Model->find_or_create(user,{
        name => nekokak,
        mail => nekokak _at_ gmail.com,
    });



XXXfind_or_insertXXXXXfind_or_createXXXXXXXXXXXXXXXXXXXXXXXOKXX



    my $row = Proj::Model->find_or_insert(user,{
        name => nekokak,
        mail => nekokak _at_ gmail.com,
    });



    single / search / search_named /search_by_sql / count

single

userXXXXXXXXXXXXXXXXXXXXXX



    my $row = Proj::Model->single(user,{name => nekokak});



search

userXXXXXXXXselectXXXXXXXXXXXsearchXXXXXXXXXXX



    my $itr = Proj::Model->search(user,
        {
            name => nekokak,
        },
        { }
    );



XXXXhashrefXXXXX XXXXhashrefXorderXlimitXXXXXXXXXXXXXX

searchXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXX XXXXXXXXXXXXXXXXXDBIx::Skinny::IteratorXXXXXX XXXXXXXXXXXXXXXXXXRowXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXDBIx::Class::Manual::JA::ResultsetXXXXXXXXXXX

search_named

selectXXXXXXXXXXXnamedXXXXXXXXXXXXX SQLXXXXXXXXXXXXXX



    my $itr = Proj::Model->search_named(q{SELECT * FROM user WHERE id > :id}, {id => 1});



XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXHashrefXXXXXXX XXXXXX’:id’XXXXXXXXHashrefXidXvalueXXX1XXXXXXXXXX

XXX%sXXXXXXXSQLXXXXXXXXXXXXX



    my $itr = Proj::Model->search_named(q{SELECT * FROM user WHERE id > :id LIMIT %s}, {id => 1}, [10]);



LIMITXXXXBindXXXXXXXXXXXXXXXXXXXXXX XXXXXXXarrayrefXXXXXXXXXX



    my $itr = Proj::Model->search_named(q{SELECT * FROM user WHERE id > :id LIMIT %s}, {id => 1}, [10], user);



XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX

search_by_sql

selectXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



    my $itr = Proj::Model->search_by_sql(q{SELECT * FROM user WHERE id = ?}, [1], user);



XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXbindXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

count

userXXXXXcountXXXXXXXXcountXXXXXXXXXXX



    my $count = Porj::Model->count(user , id, {name => nekokak});



XXXXXXXcountXXXXXXXXXXXXXX XXXXXXXcountXXXXXXXXXXX

    resultset

DBIx::Skinny::Manual::JA::ResultsetXXXXXXXXXX

    XXXXXXXX

SkinnyXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



    my $txn = Porj::Model->txn_scope;
   
    my $row = Proj::Model->single(user, {id => 1});
    $row->set({name => nekokak});
    $row->update;
   
    $txn->commit;



SkinnyXXXXXXXXXXXXXXtxn_scopeXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX $txn->commitXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $txn->commitXXXXXXX$txnXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXrollbackXXXXX

txn_scopeXXXXXXXXX



    Proj::Model->txn_begin;
   
    my $row = Proj::Model->single(user, {id => 1});
    $row->set({name => nekokak});
    $row->update;
   
    Proj::Model->txn_commit;
    Proj::Model->txn_end;



XXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXRDBMSXXXXXXXXXXXXXXXXXXXXXXXXXXXXX MySQLXXXXXXXXInnoDBXXXXXXXXX

    XXXXXXX(Mixin)

DBIx::Skinny::MixinXXXXXXXXXXXX Proj::ModelXXXXXXXXXXXXXXXXXXX

XXX



    package Proj::Model;
    use DBIx::Skinny;
    use DBIx::Skinny::Mixin modules => [+Mixin::Foo];
    1;
   
    package Mixin::Foo;
    sub register_method {
        +{
            foo => sub { foo },
        };
    }



XXXXXMixin::FooXXXXXXregister_methodXXXXXXX Proj::ModelXXXXXXexportXXXXX

XXXXXXfooXXXXXXXXexportXXXXX



    Proj::Model->foo;



XXXXXXXXXXXXXX

    RowXXXXXXXXXXXXXX

Proj::Model::Row::{Table}XXXXXXXXXXXXXXXX SkinnyXIteratorXXXXXXRowXXXXX XXXXXXXXXXXProj::Model::Row::{Table}XXXXXXXXXX

TableXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXSQLXDigest::SHA1XXXXXXXXXXXXXANONXXXXXXXXXXXXX

TableXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



    package Proj::Model::Row::User;
    use strict;
    use warnings;
    use utf8;
    use base DBIx::Skinny::Row;
    sub foo {
        say foo;
    }
    1;



fooXXXXXXXXXXXXX



    $row->foo;



XXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXUser has_many BlogXXX



    package Proj::Model::Row::User;
    use base DBIx::Skinny::Row;
    sub blogs {
        my $self = shift;
        $self->{skinny}->search(blog,{user_id => $self->id});
    }



XXXXXXXXXXXX



    $user->blogs;



XXXXXXXXXXXXXXXXXXX

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DBIX::SKINNY::MANUAL::JA::INTRO (3) 2010-11-08

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.