Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7934845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:44:57+00:00 2026-06-03T21:44:57+00:00

I´ve checked already this but my error seems to be different. I´m getting this

  • 0

I´ve checked already this but my error seems to be different.

I´m getting this error:

[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 [] []

This is my 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();
    }    
}

This my controller, where I call the repository:

$em = $this->getDoctrine()->getEntityManager();
$operarios = $em->getRepository('GitekUdaBundle:Operario')->findOperariosordenados();   

Finally, this is my Entity:

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

Any help or clue??

Thanks in advance

EDIT: Works fine on dev environment, but no in prod environment.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:44:58+00:00Added an answer on June 3, 2026 at 9:44 pm

    You already are in a reposoritory, you do not need to re-get it.

    All methods in a *Repository can be used as with $this

    Also, note

    • Query Builder or Hand made Query is way too much work when a simple return $this->findBy(); can be used.
    • findBy() has three parameters, first is an array of relations and getters, the second is for ordering, see Doctrine\ORM\EntityRepository code
    • Instead of using Raw queries… try the query builder FIRST. Look at my sample.

    Your code

    I would suggest you simply do:

    public function findOperariosordenados()
    {
        $collection = $this->findBy( array(), array('apellidos','nombre') );
        return $collection;
    } 
    

    You only need EntityRepository

    One of my repositories:

    Things to note:

    • Order has a relationship as $owner using the User Entity
    • If you REALLY need an array, in $array = $reposiroty->getOneUnhandledContainerCreate(Query::HYDRATE_ARRAY)
    • The ContainerCreateOrder is an extend of Order in a @ORM\InheritanceType("SINGLE_TABLE"). Quite out of scope of this question though.

    It could be helpful:

     <?php
    
    namespace Client\PortalBundle\Entity\Repository;
    
    
    # Internal
    use Doctrine\ORM\EntityRepository;
    use Doctrine\ORM\QueryBuilder;
    use Doctrine\ORM\Query;
    use Doctrine\Common\Collections\ArrayCollection;
    
    
    # Specific
    
    
    # Domain objects
    
    
    # Entities
    use Client\PortalBundle\Entity\User;
    
    
    # Exceptions
    
    
    
    /**
     * Order Repository
     *
     *
     * Where to create queries to get details
     * when starting by this Entity to get info from.
     *
     * Possible relationship bridges:
     *  - User $owner Who required the task
     */
    class OrderRepository extends EntityRepository
    {
    
        private function _findUnhandledOrderQuery($limit = null)
        {
            $q = $this->createQueryBuilder("o")
                    ->select('o,u')
                    ->leftJoin('o.owner', 'u')
                    ->orderBy('o.created', 'DESC')
                    ->where('o.status = :status')
                    ->setParameter('status',
                        OrderStatusFlagValues::CREATED
                    )
                    ;
    
            if (is_numeric($limit))
            {
                $q->setMaxResults($limit);
            }
            #die(var_dump( $q->getDQL() ) );
            #die(var_dump( $this->_entityName ) );
            return $q;
        }
    
    
        /**
         * Get all orders and attached status specific to an User
         *
         * Returns the full Order object with the
         * attached relationship with the User entity
         * who created it.
         */
        public function findAllByOwner(User $owner)
        {
            return $this->findBy( array('owner'=>$owner->getId()), array('created'=>'DESC') );
        }
    
    
    
        /**
         * Get all orders and attached status specific to an User
         *
         * Returns the full Order object with the
         * attached relationship with the User entity
         * who created it.
         */
        public function findAll()
        {
            return $this->findBy( array(), array('created'=>'DESC') );
        }
    
    
    
        /**
         * Get next unhandled order
         *
         * @return array|null $order
         */
        public function getOneUnhandledContainerCreate($hydrate = null)
        {
           return $this->_findUnhandledOrderQuery(1)
                        ->orderBy('o.created', 'ASC')
                        ->getQuery()
                        ->getOneOrNullResult($hydrate);
        }
    
    
    
        /**
         * Get All Unhandled Container Create
         */
        public function getAllUnhandledContainerCreate($hydrate = null)
        {
           return $this->_findUnhandledOrderQuery()
                        ->orderBy('o.created', 'ASC')
                        ->getQuery()
                        ->getResult($hydrate);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have checked a lot of threads already but none of them seems to
I have already checked many questions in StackOverflow but none of them worked for
Recently I am getting this error when using msysgit, in particular when there is
I've checked this question and it seems to be related to what I need,
This is probably not possible, since I already checked the list of all GHC
I am trying to display my iphone/Ipad app on my iPad but getting this
I receive an empty value for NSMutableArray and already checked that was filled properly.
I checked out the three20 source and was trying to follow this guide to
I checked all the topics, but i simply don't know why my script does
I checked on other postings and suggested to make the EnableHeadersVisualStyles = false but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.