Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2015-11-28 09:11 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (740 votes), past polls