使用DBIx :: Class执行set操作的最佳方法是什么? 我看到一个解决方案是根据我的查询创建一个Result Source,但我的条件将由用户定义,我不知道最好的答案是动态创建结果源。
基本上我需要将此类查询转换为DBIC,其中code
,attr_name
和value
由用户定义:
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'
)
)