Answer the question
In order to leave comments, you need to log in
How to work with Doctrine 2 custom repositories?
There is a Place entity, I add a custom repository, as described here 8.8.7: odiszapc.ru/doctrine/working-with-objects/#881
and when calling the method of this repository, it gives an error that there is no such method. Maybe I wrote something wrong, or do I need to add an entry somewhere else? I use ZF2.
Entity\Place code:
namespace Application\Entity;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* Application\Entity\Place
* @ORM\Entity(repositoryClass="Application\Entity\PlaceRepository")
*
*/
/** @ORM\Entity */
class Place {
/***тут поля Place***/
}
class PlaceRepository extends EntityRepository{
public function getAll(){
return $this->_em->createQuery('SELECT u FROM Application\Entity\Place u')->getResult();
}
}
$places=$em->getRepository('Application\Entity\Place')->getAll();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question