我是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 回答
你有没有把所有必要的注释都放到所有类中,就像在这里说的那样:http://symfony.com/doc/current/doctrine/repository.html?您使用的是最新的Symfony 2.0.5吗?