Hi there,
Thanks a lot for you answer! Although it did not exactly answer my question it taught me a LOT about DBIC that I did not know yet. Thanks for that!
What I was actually looking for was fetching all many_to_many related objects without exactly knowing the names of the relations.
I have solved it by doing:
my @related_models;
# fetch relations from model. By doing it this way when new many_t
+o_many relations are created, the controller automatically picks them
+ up
my @relations = $self->schema->source('Document')->relationships()
+;
foreach (@relations) {
if ($_ =~ m/(^.*)_documents$/) {
push @related_models, $1;
}
}
foreach (@related_models) {
my ($relObj) = $object->$_(); #Assume only one object refe
+rs to this one (business logic)
if ($relObj) {
$row{relatedObject} = $relObj->name();
$row{relatedObjectId} = $relObj->id();
$row{relatedObjectType} = $relObj->_source_handle->sou
+rce_moniker; # Why is getting the source Name so difficult?
}
}
push @data, \%row;
}
Again thanks for the very informative reply!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|