Phi*_*mon 5 symfony doctrine-orm
我是symfony 2的新手.我正在尝试在symfony中使用自定义存储库2.在detailsRepository.php文件中编写该函数之后.在我写的控制器中
$em = $this->getDoctrine()->getEntityManager();
$products = $em->getRepository('BundlesampleBundle:details')
->findAllWhoseEmailContains($value);
Run Code Online (Sandbox Code Playgroud)
但我得到的错误是
警告:缺少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();
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
您是否为所有类添加了所有必要的注释,就像这里所说的: http: //symfony.com/doc/current/doctrine/repository.html?您使用的是最新的 Symfony 2.0.5 吗?
归档时间: |
|
查看次数: |
6215 次 |
最近记录: |