简体   繁体   English

具有simple_array的Dctrine DQL IN子句

[英]Doctrine DQL IN clause with simple_array

I need to check cpv.text (simple_array type Doctrine2 (1,2,5,6)) for pr.id contained in it. 我需要检查cpv.text(simple_array类型Doctrine2(1,2,5,6))中包含的pr.id。 Is there any other way to do this? 还有其他方法吗? My query isn't working, cuz I'm using IN clause wrong. 我的查询无法正常工作,因为我使用的IN子句错误。 Sorry for my English. 对不起我的英语不好。

return  $this->getEntityManager()
->createQuery(("SELECT c, cpv, pr, p "
. "FROM AmoMainBundle:Company c "
. "JOIN c.status s "
. "JOIN cpv.param p "
. "JOIN c.country co "
. "JOIN p.props pr "
. "WHERE  EXISTS (SELECT p2 FROM AmoMainBundle:Param p2 "
. "LEFT JOIN p2.props pr2 "
. "LEFT JOIN p2.companyParameterValues cpv2 "
. "WHERE (p2.type >=2 AND pr2.text LIKE ?1 "
. "AND pr2.id IN (cpv2.text) AND p2.name LIKE ?2) "
. "OR (p2.type < 2 AND p2.name LIKE ?2)) "
. "AND (s IS NULL OR s.dateto < CURRENT_TIMESTAMP()) "
. "ORDER BY c.lastupd DESC, "
. "c.name ASC, p.mainPriority DESC" )
                    ->setParameter(1,$text)->setParameter(2, $name);

It's impossible, cuz doctrine store array and simple_array data like text. 因为cuz教义存储数组和诸如文本的simple_array数据是不可能的。 It converted to PHP array after hydration. 水合后将其转换为PHP数组。 All possible types and docs . 所有可能的类型和文档 So need to use full-text search, but my table engine is InnoDB. 所以需要使用全文搜索,但是我的表引擎是InnoDB。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM