Doctrine orm 在Symfony 2中使用自定义存储库时显示错误?
我是symfony 2的新手。我正在尝试使用symfony 2中的自定义存储库。在detailsRepository.php文件中写入函数后。在我写的控制器里Doctrine orm 在Symfony 2中使用自定义存储库时显示错误?,doctrine-orm,symfony,Doctrine Orm,Symfony,我是symfony 2的新手。我正在尝试使用symfony 2中的自定义存储库。在detailsRepository.php文件中写入函数后。在我写的控制器里 $em = $this->getDoctrine()->getEntityManager(); $products = $em->getRepository('BundlesampleBundle:details') ->findAllWhoseEmailContains($value);
$em = $this->getDoctrine()->getEntityManager();
$products = $em->getRepository('BundlesampleBundle:details')
->findAllWhoseEmailContains($value);
但我得到的错误是
警告:在第162行的C:\xampp\htdocs\symblog\src\Bundle\sampleBundle\Controller\DefaultController.php中调用并在C:\xampp\htdocs\symblog\vendor\doctor\lib\doctor\ORM\EntityRepository.php第61行中定义的条令\ORM\EntityRepository::\uu构造()缺少参数1(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();
}
}
您是否像这里所说的那样,为所有类添加了所有必要的注释:?
您正在使用最新的Symfony 2.0.5吗?hai。。。谢谢你的回复。。。我已经用我的detailsRepository.php文件中的内容更新了这个问题。我忘了提到。。。我使用的是symfony 2.0.5。@Philemon有没有用@ORM\entity(repositoryClass=“XXX”
>)注释过你的实体类?还有一个名为“Bundle”的包的名称空间看起来很奇怪。你为什么不把它叫做Philemon
?hai FractalizeR,很抱歉,我不能理解这个“@ORM\entity(repositoryClass=“XXX”)这是我构建类时自动生成的。请解释。请看这里: