我有一个过滤器,可以过滤该项目的标签数量。但我不能让它工作它会给我一个错误:
查询返回了多行。更改查询或使用不同的结果函数,如getScalarResult()。
在我的物品实体中:
/**
* @var integer
*
* @ORM\ManyToOne(targetEntity="Item", inversedBy="tags")
*/
private $clip;
在我的代码实体
中->add('tag', 'doctrine_orm_callback', array(
'label' => 'Keywords',
'callback' => function($queryBuilder, $alias, $field, $value) {
if (!isset($value['value'])) {
return;
}
$operators = array(
NumberType::TYPE_EQUAL => '=',
NumberType::TYPE_GREATER_EQUAL => '>=',
NumberType::TYPE_GREATER_THAN => '>',
NumberType::TYPE_LESS_EQUAL => '<=',
NumberType::TYPE_LESS_THAN => '<',
);
$operator = $operators[$value['value']['type']];
$queryBuilder->leftJoin(sprintf('%s.%s', $alias, $field), 't');
$queryBuilder->having('COUNT(ct) '.$operator.' :count');
$queryBuilder->groupBy('t.item');
$queryBuilder->setParameter('count', $value['value']);
},
'field_type' => 'number',
))
在ItemAdmin的configureDatagridFilters
中SELECT * FROM [Sheet1$] WHERE ([Field Name in Brackets] = SomeNumericValue)
SELECT * FROM [Sheet1$] WHERE ([Field Name in Brackets] = 'SomeTextValueInSingleQuote')
SELECT * FROM [Sheet1$] WHERE ([Field Name in Brackets] = #SomeDateInHashTags#)