给定模型,其中有一个包含字符串数组的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? */ )