Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
类存储库在symfony 2中不起作用_Symfony_Repository - Fatal编程技术网

类存储库在symfony 2中不起作用

类存储库在symfony 2中不起作用,symfony,repository,Symfony,Repository,这是我的密码: 文件Entity/Article.php 文件实体/存储库: namespace Kaker\FormularzBundle\Entity; use Doctrine\ORM\EntityRepository; class ArticleRepository extends EntityRepository { public function getNickInfo($nick) { return $this->getEntityManager(

这是我的密码:

文件Entity/Article.php

文件实体/存储库:

namespace Kaker\FormularzBundle\Entity;

use Doctrine\ORM\EntityRepository;

class ArticleRepository extends EntityRepository
{
    public function getNickInfo($nick)
    {
    return $this->getEntityManager()
        ->createQuery(
            'SELECT a FROM KakerFormularzBundle:Article a WHERE a.nick = :nick '
        )
        ->setParameter('nick', $nick)
        ->getResult();
    }
}
文件用户控制器

$em = $this->getDoctrine()->getManager();
$article = $em->getRepository("KakerFormularzBundle:Article")
            ->getNickInfo($nick);
我有一个错误:

警告:在第1496行的/var/www/apps/sf2 podstwy/app/cache/dev/appDevDebugProjectContainer.php中调用并定义的条令\ORM\EntityRepository::uu构造缺少参数1


可能重复的您是否确定您没有尝试在某个地方创建新的ArticleRepository?也许您已经将它定义为一个服务,并且正在尝试将它注入到某些东西中。通常,使用EntityManager::getRepository$entityClassName创建存储库。您的特定错误消息表明有东西正试图直接新建它$rows=$em->getRepositoryKakerFormularzBundle:Article->getAllArticle;,但是在UserController中,相同的代码不起作用
$em = $this->getDoctrine()->getManager();
$article = $em->getRepository("KakerFormularzBundle:Article")
            ->getNickInfo($nick);