【发布时间】:2014-09-28 00:22:51
【问题描述】:
给定模型Post,其中有一个字段tags,其中包含一个字符串数组,例如:
Post:
id: 1
tags: ['a', 'b', 'c']
Post:
id: 2
tags: ['a', 'z']
如何构造查询,以获取包含数组['a', 'b'] 中所有值的模型(在本例中,仅返回 Post id 1)?
我一直在考虑这些:
使用 Doctrine ODM QueryBuilder:
// is this correct?
$qb->expr()->field('tags')->all( array('a', 'b') );
使用 Doctrine ORM QueryBuilder:
$qb->expr()->all( /* the docs say to use DQL here.. is there no QueryBuilder alternative? */ )
【问题讨论】:
标签: orm doctrine-orm query-builder odm