doctrine-orm - 在 Symfony 2 中使用自定义存储库时显示错误?

标签 doctrine-orm symfony

我是 symfony 2 的新手。我试图在 symfony 2 中使用自定义存储库。在 detailsRepository.php 文件中编写函数后。在我写的 Controller 中

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

但我收到的错误是

Warning: Missing argument 1 for Doctrine\ORM\EntityRepository::__construct(), called in C:\xampp\htdocs\symblog\src\Bundle\sampleBundle\Controller\DefaultController.php on line 162 and defined in C:\xampp\htdocs\symblog\vendor\doctrine\lib\Doctrine\ORM\EntityRepository.php line 61 (500 Internal Server Error)



我的 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();


    }   

}

提前致谢。

最佳答案

您是否为所有类添加了所有必要的注释,就像这里所说的:http://symfony.com/doc/current/doctrine/repository.html ?
您使用的是最新的 Symfony 2.0.5 吗?

关于doctrine-orm - 在 Symfony 2 中使用自定义存储库时显示错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8075258/

相关文章:

php - 原则 2 - 一对多单向

symfony - 有没有办法在 SQLFilter 中访问 symfony2 容器?

symfony - 奏鸣曲管理员通过显示链接更改编辑链接

symfony - SonataAdminBundle model_type 值以过滤器形式过滤

php - Symfony:如何获取所有服务及其各自的类

mysql - SQL 问题,相互约束, "a foreign key constraint fails"

php - 有什么想法可以改进我的徽章系统吗?

php - Symfony 表单错误 - 名称为空的表单不能有父表单

mysql - Symfony2.2 Swiftmailer 无法在 AWS-EC2 服务器站点中工作

php - 可翻译 Doctrine 实体的 Symfony 表单