Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: list DBIX::Class many_to_many relations

by misterb101 (Sexton)
on Dec 22, 2010 at 16:03 UTC ( #878577=note: print w/replies, xml ) Need Help??


in reply to Re: list DBIX::Class many_to_many relations
in thread list DBIX::Class many_to_many relations

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!
--
Cheers,
Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://878577]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2023-04-02 00:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?