以下代码导致未捕获异常:
类视觉
echo(ProdutoController::listaProdutoVitrineFiltroOrdenadoPeloMenor("TV", "nome", "precodevenda", "ASC"));
类控制器
$produtos = daogenerico::findByStringOrderBy("Produto", $tipopesquisa, $nome, $parametro, $ordem);
道
public static function findByStringOrderBy($classname, $field, $string, $order, $orderparam){
$bd = new bd();
$bd->conectar();
$result = $bd->getEntityManager()->getRepository($classname)->createQueryBuilder('e')
->where('e.'.$field.' LIKE :'.$field)
->setParameter($field, '%'.$string.'%')
->orderBy($order, $orderparam)
->getQuery()
->getResult();
return $result;
}
错误:
致命错误:未捕获的异常' Doctrine \ ORM \ Query \ QueryException'有消息' SELECT e FROM Produto e WHERE e.nome LIKE:nome ORDER BY precodevenda ASC'在C:\ xampp \ htdocs \ TrabalhoA2 \ vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ Query \ QueryException.php:41堆栈跟踪:#0 C:\ xampp \ htdocs \ TrabalhoA2 \ vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ Query \ Parser.php(483):Doctrine \ ORM \ Query \ QueryException :: dqlError(' SELECT e FROM P ...')#1 C:\ xampp \ htdocs \ TrabalhoA2 \ vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ Query \ Parser.php(708):Doctrine \ ORM \ Query \ Parser-> semanticalError('' precodevenda' ... ',数组)#2 C:\ xampp \ htdocs \ TrabalhoA2 \ vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ Query \ Parser.php(283):Doctrine \ ORM \ Query \ Parser-> processDeferredResultVariables ()#3 C:\ xampp \ htdocs \ TrabalhoA2 \ vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ Query \ Parser.php(351):Doctrine \ ORM \ Query \ Parser-> getAST()#4 C :\ xampp \ htdocs \ TrabalhoA2 \ vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ Query.php(281):Doctrine \ ORM \ Query \ Parser-> parse()#5 C:\ xampp \ htdocs \ TrabalhoA2 C:\ xampp \ htdocs \ TrabalhoA2 \ vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ Query \ QueryExcep中的\ vendor \ doctrine \ orm \ lib \ Doctri第63行的.php
有人可以帮忙吗?
答案 0 :(得分:2)
似乎是实体别名' e'在订单栏' precodevenda'前面缺少。 尝试更换:
->orderBy($order, $orderparam)
带
->orderBy('e.'.$order, $orderparam)