[Dbix-class] how to use a complex query in DBIx::Class
Jess Robinson
castaway at desert-island.demon.co.uk
Sat Dec 30 02:32:08 GMT 2006
On Tue, 26 Dec 2006, Matt LeBlanc wrote:
> On 12/26/06, Jess Robinson <castaway at desert-island.demon.co.uk> wrote:
>> $schema->resultset('boards')->search({
>> 'hiddenboards.userId' => 3,
>> 'me.active' => 1,
>> }, {
>> 'join' => 'hiddenboards',
>> '+select' => [ 'hiddenboards.userId' ],
>> '+as' => [ 'hidden' ],
>> 'order_by' => [ 'pos' ],
>> })
>>
>>
>> .. and set up the relationship between board and hiddenboards to use an
>> inner join, not a left join.
>>
>> I've not seen the syntax "SELECT .. hiddenboards.userId IS NOT NULL as
>> hidden" .. it's odd, why not use the proper join type?
>>
>> Jess
>
> ... this isn't the same thing. He does not want all of the hidden
> boards, as your change to an inner join would return. He wants all
> boards with an extra field that tells him whether or not the board is
> hidden (if the left join doesn't work, hiddenboards.boardId is null
> and as such hidden is false).
>
Oh! That makes a lot more sense.. OTOH the JOIN .. ON ..
hiddenboards.userId = 3 surely negates that effect?
Jess
More information about the Dbix-class
mailing list