开发者

Set operations in DBIx::Class

What is the best way to perform set operations using DBIx::Class? I saw that one solution would be to create a Result Source based on my query, but my c开发者_StackOverflowonditions will be defined by the user and I don know if the best answer is to create the result source on the fly.

Basically i need to translate this type of query to DBIC where code, attr_name and value is defined by the user:

SELECT pid FROM product WHERE code = 48
INTERSECT
(
  ( SELECT pid FROM attr WHERE attr_name = 'color' AND value = 'blue'
    INTERSECT
    SELECT pid FROM attr WHERE attr_name = 'size' AND value = 'big'
  )
  UNION
  ( SELECT pid FROM attr WHERE attr_name = 'color' AND value = 'green'
    INTERSECT
    SELECT pid FROM attr WHERE attr_name = 'size' AND value = 'small'
  )
)


Could DBIx::Class::Helper::ResultSet::SetOperations be what you need?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜