我正在使用 Symfony2 和 DQL 开发一个应用程序,用于在存储库中构建一些查询。我在控制器中有下一个代码:
$emGalPak = $this->getDoctrine()->getEntityManager();
$OsatugabeKop = $emGalPak->getRepository('AnotatzaileaAnotatzaileaBundle:GalderaPaketea')
->getOsatugabeKop();
这是我在与上述实体对应的存储库中构建的查询:
<?php
namespace Anotatzailea\AnotatzaileaBundle\Repository;
use Doctrine\ORM\EntityRepository;
/**
* GalderaPaketeaRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class GalderaPaketeaRepository extends EntityRepository
{
public function getOsatugabeKop()
{
$qb = $this->createQueryBuilder('c')
->select('c')
->where('c.Osatua = 0')
$Emaitza = $qb->getQuery()->getResult();
return sizeof($Emaitza);
}
}
运行代码时,它显示下一个错误:
Parse error: syntax error, unexpected T_VARIABLE in /var/www/Symfony/src/Anotatzailea/AnotatzaileaBundle/Repository/GalderaPaketeaRepository.php on line 20
关于如何解决此错误的任何想法?