【发布时间】:2017-10-06 09:19:26
【问题描述】:
我收到了这个错误:
可捕获的致命错误:类的对象 Symfony\Component\HttpFoundation\ParameterBag 无法转换 串起来
我使用 Symfony 3 和 Doctrine Query Builder
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('c')
->from('AppBundle:Certificate', 'c')
->where(' c.enabled = 1')
->where(' c.title LIKE :search')
->orderBy('c.title', $order)
->setParameter('search', '%' . $search . '%' );
$query = $qb->getQuery();
return $query->getResult();
我尝试像这样将 _toString 添加到我的实体中:
public function __toString() {
return $this->title;
}
但我没有更改它,我将需要使用 c 列进行相同的搜索与 LIKE where(cc1 LIKE: search OR cc2 LIKE: search)
有什么解决办法吗?我需要使用 LIKE 搜索给定搜索字符串的两列,并且我必须使用 %:search%
谢谢
【问题讨论】:
-
我们需要更多的上下文。
$order和$search变量的值是多少? -
您收到此错误是因为您尝试在字符串上下文中使用 ParameterBag 对象。它与您的实体无关。
-
我觉得你找错地方了:检查你使用request或者session的地方的错误(通常使用对象parameterBag的地方)
标签: php symfony doctrine-orm