スキーマの設定方法(Schema-Loader)

myapp.pl

 #!/usr/bin/env perl
 
 use strict;
 use warnings;
 use MyDB;
 
 my $db = MyDB->new;
 my $connect_info =
   { dsn => 'dbi:Pg:dbname=mydb;host=localhost', username => 'postgres', password => '' };
 $db->connect($connect_info);
 $db->schema->load_schema($connect_info);
 my $row = $db->search( 't1', { name => 'taro' } )->next;
 print $row->id . "\n";

MyDB.pm

 package MyDB;
 
 use strict;
 use warnings;
 use DBIx::Skinny;
 
 1;

MyDB/Schema.pm

 package MyDB::Schema;
 
 use strict;
 use warnings;
 use base qw/DBIx::Skinny::Schema::Loader/;
 use DBIx::Skinny::Schema;
 
 1;

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2011-06-11 (土) 06:19:14