0

私は、タグと並べ替え順序を使用してマーケットプレイスを作成していますが、タグは適切に機能しますが、並べ替えコードがあると、次のように表示されます。

Catchable Fatal Error: Object of class \Entity\Category could not beconverted to
string in \vendor\doctrine\orm\lib\Doctrine\ORM\Query\Expr.php line 568

私はグーグルで検索しましたが、誰も同じ問題を抱えていませんでしたか?私のコード:

public function tagAction($tag, $sort) {

    $rep = $this->getDoctrine()
            ->getRepository('RSHubMarketplaceBundle:Modification');
    $tags = $this->getDoctrine()
    ->getRepository('RSHubMarketplaceBundle:Category')
    ->findAll();
    if($tag == -1){
            $stags = $tags;

    } else {
        $tag = $this->getDoctrine()
    ->getRepository('RSHubMarketplaceBundle:Category')
    ->find($tag);
        $stags = array($tag); 
    }
    switch ($sort) {
    case 'popularity':
        $mods = $rep->getByPopularity( array($tag));
        break;
    case 'downloads':
        $mods = $rep->getByDownloads( array($tag));
        break;
    case 'newest':
        $mods = $rep->getByNewest(array($tag));
        break;
    case 'name':
        $mods = $rep->getByName( array($tag));
        break;

    }
    return $this->render('RSHubMarketplaceBundle:Marketplace:index.html.twig',
                    array('categories' => $tags, 'mods' =>$mods,
                            'tag' => $tag));
}

そして、私が問題に遭遇した方法:

public function getWithCategoriesOrdered(array $nom_categories, $orderCol, $order) {
    $qb = $this->createQueryBuilder('a');

    $qb->join('a.categories', 'c')
            ->where($qb->expr() // HERE
                    ->in('c.name', $nom_categories));
    $qb->add('orderBy', 'a.'.$orderCol.' '.$order);

    return $qb->getQuery()
            ->getResult();
}
4

1 に答える 1