我已经检查过了,但我的错误似乎有所不同。
我收到此错误:
[2012-05-07 14:09:59] request.CRITICAL: BadMethodCallException: Undefined method 'findOperariosordenados'. The method name must start with either findBy or findOneBy! (uncaught exception) at /Users/gitek/www/uda/vendor/doctrine/lib/Doctrine/ORM/EntityRepository.php line 201 [] []
这是我的 OperarioRepository:
<?php
namespace Gitek\UdaBundle\Entity;
use Doctrine\ORM\EntityRepository;
/**
* OperarioRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class OperarioRepository extends EntityRepository
{
public function findOperariosordenados()
{
$em = $this->getEntityManager();
$consulta = $em->createQuery('SELECT o FROM GitekUdaBundle:Operario o
ORDER BY o.apellidos, o.nombre');
return $consulta->getResult();
}
}
这是我的控制器,我在其中调用存储库:
$em = $this->getDoctrine()->getEntityManager();
$operarios = $em->getRepository('GitekUdaBundle:Operario')->findOperariosordenados();
最后,这是我的实体:
<?php
namespace Gitek\UdaBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Gitek\UdaBundle\Entity\Operario
*
* @ORM\Table(name="Operario")
* @ORM\Entity(repositoryClass="Gitek\UdaBundle\Entity\OperarioRepository")
*/
class Operario
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $nombre
*
* @ORM\Column(name="nombre", type="string", length=255)
*/
private $nombre;
----
----
任何帮助或线索?
提前致谢
编辑:在开发环境中工作正常,但在生产环境中没有。