DBIx::Class::ProxyTable - without generating a schema
package Your::Schema; use base 'DBIx::Class::Schema'; __PACKAGE__->load_classes(qw//); package Your::Schema::Log; use base 'DBIx::Class'; __PACKAGE__->load_components(qw/ProxyTable Core/); __PACKAGE__->table('log'); __PACKAGE__->add_columns(qw/ id body /); __PACKAGE__->set_primary_key('id'); 1; # in your script: my $rs = $schema->resultset('Log'); $rs->proxy('log2')->create({id => 1, body => 'hoge'}); # insert data for log2 table my $log2 = $rs->proxy('log2')->single({id => 1});
The cause can treat a table becoming the base in DBIC without generating a schema. and auto create target table.
# get Log's resultset my $rs = $schema->resultset('Log'); # insert data to log2 table $rs->proxy('log2')->create({id => 1, body => 'bar'});
now: $schema->resultset('Log')->proxy('log2')->create({id => 1, body => 'hoge'});
but 'log2' does not do proxy. Is this place better?
$schema->proxy('Log','log2')->create({id => 1, body => 'hoge'});
or
$schema->proxy('Log')->table('log2')->create({id => 1, body => 'hoge'});
$schema->resultset('Log')->proxy_to('log2')->create({id => 1, body => 'hoge'});
any more idea?
No bugs have been reported.
Atsushi Kobayashi <nekokak __at__ gmail.com>
<nekokak __at__ gmail.com>
Copyright (c) 2007, Atsushi Kobayashi <nekokak __at__ gmail.com>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install DBIx::Class::ProxyTable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class::ProxyTable
CPAN shell
perl -MCPAN -e shell install DBIx::Class::ProxyTable
For more information on module installation, please visit the detailed CPAN module installation guide.