X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FModel%2FCDBI.pm;h=2d309904c015270349044a5b90da40014aee7b1d;hb=38deb5b0946274f649b98539bd1af06ab2741cfb;hp=031d9851e797e72497c0ec8681914dcd06766925;hpb=9b8f3c269605db27908000957b20cc3a336f9148;p=maypole.git diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index 031d985..2d30990 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -39,6 +39,8 @@ See L for these: =item setup_database +=item fetch_objects + =back =head1 Additional Commands @@ -233,4 +235,15 @@ sub class_of { return $r->config->loader->_table2class($table); } +sub fetch_objects { + my ($class,$r)=@_; + my @pcs = $class->primary_columns; + if ( $#pcs ) { + my %pks; + @pks{@pcs}=(@{$r->{args}}); + return $class->retrieve( %pks ); + } + return $class->retrieve( $r->{args}->[0] ); +} + 1;