| MetaStore documentation | Contained in the MetaStore distribution. |
MetaStore::Cmetalinks - class for collections of data, stored in database.
use MetaStore::Cmetalinks;
my $links = new MetaStore::Cmetalinks::
dbh => $dbh,
table => 'metalinks',
field => 'lsrc';
Class for collections of data, stored in database.
MetaStore, Collection::AutoSQLnotUnique,README
Zahatski Aliaksandr, <zag@cpan.org>
Copyright (C) 2006-2008 by Zahatski Aliaksandr
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
| MetaStore documentation | Contained in the MetaStore distribution. |
package MetaStore::Cmetalinks;
use strict; use warnings; use Data::Dumper; use Collection::AutoSQLnotUnique; use Collection::AutoSQL; our @ISA = qw(Collection::AutoSQLnotUnique); sub after_load { my $self = shift; my %attr = (); foreach my $rec (@_) { my ($name,$val, $type ) = @{$rec}{qw/ lid ldst lex/}; $attr{$type}{$name} = $val } while ( my ($type, $list) = each %attr) { $attr{$type} = [ map { $list->{$_} } sort { $a <=> $b } keys %$list ] } return \%attr; } sub before_save { my $self = shift; my $attr = shift; my @res; while ( my ($type, $array ) = each %$attr) { $array ||= []; my $i; foreach my $rec (@$array) { $i++; push @res,{ ldst=>$rec , lid=>$i, lex => $type } } } return \@res } sub _prepare_record { my $self = shift; my ( $key, $ref ) = @_; return $self->Collection::AutoSQL::_prepare_record($key,$ref); } 1; __END__