Revision ea20c6e3
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/DB/Helper/LinkedRecords.pm | ||
---|---|---|
22 | 22 |
"${myself}_id" => $self->id ); |
23 | 23 |
|
24 | 24 |
if ($params{$wanted}) { |
25 |
my $wanted_table = SL::DB::Helpers::Mappings::get_table_for_package($params{$wanted}) || croak("Invalid parameter `${wanted}'"); |
|
26 |
push @query, ("${wanted}_table" => $wanted_table); |
|
25 |
my $wanted_classes = ref($params{$wanted}) eq 'ARRAY' ? $params{$wanted} : [ $params{$wanted} ]; |
|
26 |
my $wanted_tables = [ map { SL::DB::Helpers::Mappings::get_table_for_package($_) || croak("Invalid parameter `${wanted}'") } @{ $wanted_classes } ]; |
|
27 |
push @query, ("${wanted}_table" => $wanted_tables); |
|
27 | 28 |
} |
28 | 29 |
|
29 | 30 |
my $links = SL::DB::Manager::RecordLink->get_all(query => [ and => \@query ]); |
... | ... | |
82 | 83 |
C<$self> (for C<direction> = C<from>). |
83 | 84 |
|
84 | 85 |
The optional parameter C<from> or C<to> (same as C<direction>) |
85 |
contains the package name of a Rose model for table limitation. If you |
|
86 |
only need invoices created from an order C<$order> then the call could |
|
87 |
look like this: |
|
86 |
contains the package names of Rose models for table limitation. It can |
|
87 |
be a single model name as a single scalar or multiple model names in |
|
88 |
an array reference in which case all links matching any of the model |
|
89 |
names will be returned. |
|
90 |
|
|
91 |
If you only need invoices created from an order C<$order> then the |
|
92 |
call could look like this: |
|
88 | 93 |
|
89 | 94 |
my $invoices = $order->linked_records(direction => 'to', |
90 | 95 |
to => 'SL::DB::Invoice'); |
Auch abrufbar als: Unified diff
linked_records(): Mehrere Model-Namen bei 'from'-/'to'-Parametern