Symfony和主义-ParameterBag无法转换为字符串 [英] Symfony and Doctrine - ParameterBag could not be converted to string

查看:111
本文介绍了Symfony和主义-ParameterBag无法转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误:


可捕获的致命错误:类
的对象Symfony\Component\HttpFoundation\无法将ParameterBag
转换为字符串

Catchable Fatal Error: Object of class Symfony\Component\HttpFoundation\ParameterBag could not be converted to string

我使用Symfony 3和Doctrine Query Builder

I use Symfony 3 and 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添加到我的实体中:

I try add _toString to my Entity like this:

public function __toString() {
        return $this->title;
    }

但我没有更改它,我将需要使用c列与LIKE相同的搜索其中(cc1相似:搜索或cc2相似:搜索)

but I have not changed it, I will need to use c columns for the same search with LIKE where(cc1 LIKE: search OR cc2 LIKE: search)

有什么解决方案吗?我需要用LIKE搜索两列,其中有给定的搜索字符串,并且必须使用%:search%

Is there any solution? I need to search with LIKE two columns in which the given search string and I must use %:search%

谢谢

推荐答案

ParameterBag对象必须用于请求对象检索的$ order或$ search参数。尝试在查询之前将其转储,以查看内部内容。

The ParameterBag object must be for your $order or $search parameters retrieve by the request object. Try to dump it before the query in order to see what there is inside.

这篇关于Symfony和主义-ParameterBag无法转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆