Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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!

--
Tommy


Comment on Re^2: Problems with DBIx::Class and SQL JOIN's
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.id', 'role.role' ], '+as' => [ 'roleid', 'role' ], rows => 10, }, );
    The plus ("+") sign is needed because 'role.id' and 'role.role' do not originate in the Users schema/table

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2014-10-01 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (38 votes), past polls