首页 文章

在Symfony 2中使用自定义存储库时出现错误?

提问于
浏览
5

我是symfony 2的新手 . 我正在尝试在symfony中使用自定义存储库2.在detailsRepository.php文件中编写该函数之后 . 在我写的控制器中

$em = $this->getDoctrine()->getEntityManager();
 $products = $em->getRepository('BundlesampleBundle:details')
            ->findAllWhoseEmailContains($value);

但我得到的错误是

警告:缺少Doctrine \ ORM \ EntityRepository :: __ construct()的参数1,在第162行的C:\ xampp \ htdocs \ symblog \ src \ Bundle \ sampleBundle \ Controller \ DefaultController.php中调用,并在C:\ xampp中定义\ htdocs \ symblog \ vendor \ doctrine \ lib \ Doctrine \ ORM \ EntityRepository.php第61行(500内部服务器错误)

我的detailsRepository.php如下

<?php

namespace Bundle\sampleBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * detailsRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */

class detailsRepository extends EntityRepository
{
    public function findAllWhoseEmailContains($value)
    {
        return $this->getEntityManager()
            ->createQuery('Select e.email from BundlesampleBundle:details e Where  e.email = :email')
            ->setParameter('email',$value)
            ->getResult();


    }   

}

提前致谢 .

1 回答

相关问题