无法在symfony2

时间:2016-02-11 12:58:11

标签: php doctrine-orm repository entity symfony

让我来描述我的问题 我在我的演示应用程序中为实体TblUserEdu创建了自定义函数。我的实体如下

TblUserEdu.php     

/**
 * @ORM\Entity(repositoryClass="UserBundle\Repository\TblUserEduRepository")
 * @ORM\Table(name="tbl_user_edu")
 */
class TblUserEdu
{

}

我在实体中映射了存储库,并在保存到路径UserBundle\Repository的存储库中创建了测试功能。

TblUserEduRepository.php

<?php
    namespace UserBundle\Repository;
    use Doctrine\ORM\EntityRepository;
    use UserBundle\Entity\TblUserEdu;

    class TblUserEduRepository extends EntityRepository
    {
        public function findEducations()
        {
            return $this->getEntityManager()
                   ->createQuery('SELECT u FROM UserBundle:TblUserEdu u WHERE u.edu_status="r"')
                   ->getResult();
        }


    }

从控制器调用函数findEducations()。 的 DefaulrController.php

$edus = $em->getRepository('UserBundle:TblUserEdu')->findEducations();

但它返回函数未定义的错误

Undefined method 'findEducations'. The method name must start with either findBy or findOneBy! 

我尝试了很多解决方案,但每次都无法解决。

0 个答案:

没有答案
相关问题