in reply to Re^2: Moose + ORM
in thread Moose + ORM
And here is what it might look like ...
package Table; use MooseX::Role::Parameterized; parameter table_name => ( isa => 'Str', required => 1, ); role { my $p = shift; my $table = $p->table_name; my $dbh = DBI->connect( ... ); my $sth = $dbh->selectall_arrayref( "describe $table" ); my @columns = ... do DBI magic here ... foreach my $col (@column) { has $col->{name} => ( is => 'rw', isa => $col->{type}, default => $col->{default}, ); } }; package MyTable; use Moose; with 'Table' => { table_name => 'my_table' };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Moose + ORM
by Anonymous Monk on Jul 24, 2009 at 12:58 UTC | |
by stvn (Monsignor) on Jul 24, 2009 at 17:15 UTC | |
by Anonymous Monk on Jul 24, 2009 at 20:38 UTC | |
by stvn (Monsignor) on Jul 24, 2009 at 21:02 UTC | |
by Anonymous Monk on Jul 27, 2009 at 14:29 UTC | |
by Anonymous Monk on Aug 05, 2009 at 20:12 UTC | |
| |
|
Re^4: Moose + ORM
by metaperl (Curate) on Jul 24, 2009 at 12:57 UTC | |
by Anonymous Monk on Jul 24, 2009 at 13:45 UTC |