On Tue, 26 Dec 2006, Wan wrote:

Like this

SELECT boards.*, hiddenboards.userId IS NOT NULL AS hidden
FROM boards LEFT JOIN hiddenboards
ON hiddenboards.userId = '3'
AND hiddenboards.boardId = boards.id
WHERE boards.active = 1
ORDER BY pos;

I want to use this query in DBIx::Class, but...


$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

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to