Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: DBIx and ManyToMany Relationships

by moritz (Cardinal)
on May 30, 2012 at 11:55 UTC ( #973270=note: print w/ replies, xml ) Need Help??


in reply to DBIx and ManyToMany Relationships

My DBIx::Class knowledge is a bit rusty, but I think what you want is

$rs->search( {}, { rows => 10, join => { contentlinks => 'content' }, prefetch => { contentlinks => 'content' }, } );

(It might be that the prefetch alone is enough, and you don't need the join; I'm not quite sure).

For constructing queries, ignore your ManyToMany -- it is not a reliationship you can use in queries (only a shortcut on the result objects), so it probably confuses you. Simply ignore it.


Comment on Re: DBIx and ManyToMany Relationships
Download Code
Re^2: DBIx and ManyToMany Relationships
by tospo (Hermit) on May 30, 2012 at 12:18 UTC

    oh yeeah, you're right, I accidentally wrote { contentlinks => 'repo' } in my above reply but of course i wouldn't make sense to link back to "repo". join => { contentlinks => 'content' } is the correct path.

    I'm also never sure whether prefetch alone is sufficient. For the cases I had so far, it seems to be but then the docs always seem to include both so I do it as well to be on the safe side just in case this behaviour is changed in future version.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-04-20 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls