5

I am new to symfony 2. I am trying to use custom repository in symfony 2. After writing the function in the detailsRepository.php file. in the controller I wrote

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

but i am getting the error as

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)

My detailsRepository.php is as follows

<?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();


    }   

}

Thanks in advance.

1 Answer 1

1

Have you put all necessary annotations to all classes, like it's said here: http://symfony.com/doc/current/doctrine/repository.html ? Are you using latest Symfony 2.0.5?

Sign up to request clarification or add additional context in comments.

6 Comments

hai... thanks for the responce... i have updated the question with the contents in my detailsRepository.php file
sorry forgot to mention... am using symfony 2.0.5.
@Philemon Have you annotated your entity class with @ORM\Entity(repositoryClass="XXX">? Also a namespace for your bundles named "Bundle" looks strange. Why didn't you call it Philemon for example?
hai FractalizeR, sorry i could not understand this " @ORM\Entity(repositoryClass="XXX" " is this a automatically generated when i build class. please explain.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.