Symfony and Doctrine - ParameterBag could not be c

2019-08-23 11:58发布

I got this error:

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

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();

I try add _toString to my Entity like this:

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

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)

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

Thank you

1条回答
相关推荐>>
2楼-- · 2019-08-23 12:29

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.

查看更多
登录 后发表回答