Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: Problems with DBIx::Class and SQL JOIN's

by Tommy (Chaplain)
on Jun 08, 2009 at 22:43 UTC ( #769710=note: print w/replies, xml ) Need Help??

in reply to Re: Problems with DBIx::Class and SQL JOIN's
in thread Problems with DBIx::Class and SQL JOIN's

Two observations:

It works... as long as you only search by one role at a time. I don't know why, but I'll take what I can get! You have my gratitude.

It does not work if you remove the plus ("+") sign from the "+select", and "+as" hash keys. Why is this so?

Could anyone shed some light on why this works? If I know why/how it works, then I'll never have to ask related questions again --I'll already know the underlying principle and be able to apply it.

Again, my thanks to you, Arunbear!

  • Comment on Re^2: Problems with DBIx::Class and SQL JOIN's

Replies are listed 'Best First'.
Re^3: Problems with DBIx::Class and SQL JOIN's
by Arunbear (Parson) on Jun 09, 2009 at 16:38 UTC
    You only get one role at a time because the search was limited to the 'friend' role. To change that you need to change the 'where' criteria in the 1st hashref:
    $c->model('DB::Users')->search_like( { 'username' => '%foo%' }, { join => { 'map_user_role' => 'role' }, '+select' => [ '', 'role.role' ], '+as' => [ 'roleid', 'role' ], rows => 10, }, );
    The plus ("+") sign is needed because '' and 'role.role' do not originate in the Users schema/table

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://769710]
NodeReaper duct tapes the vents to muffle the moaning

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2017-08-24 03:37 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (363 votes). Check out past polls.