[Dbix-class] how to use a complex query in DBIx::Class

Matt LeBlanc mleblanc at cpan.org
Wed Dec 27 00:28:19 GMT 2006


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).



More information about the Dbix-class mailing list