Pregunta

I can't Call findBy with to arrays by the following code :

    return $this->repository->findBy(array('secteur'=>$secteur),array('slug'=>$slug));

Exception :

message: "Warning: trim() expects parameter 1 to be string, array given in C:\wamp\www\Symfonyv2\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php line 1168",
¿Fue útil?

Solución

Following the current Doctrine class, the first array is the list of criteria and the second the order of the request (desc, asc) :

/**
     * Finds entities by a set of criteria.
     *
     * @param array      $criteria
     * @param array|null $orderBy
     * @param int|null   $limit
     * @param int|null   $offset
     *
     * @return array The objects.
     */
    public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);

        return $persister->loadAll($criteria, $orderBy, $limit, $offset);
    }

So your method seems to be wrong. And maybe you should do something like this (I don't know what you have in secteur and slug).

return $this->repository->findBy(array('secteur'=>$secteur,'slug'=>$slug)); 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top