user2632918
user2632918

Reputation:

find() vs. createQuery

I have the following script in symfonyproject.

use Rowoco\AllgemeinBundle\Entity\Place;
.
.

public function getPlacelist( $iduser )
{
    $em = $this->getDoctrine()->getManager();
    $request = Request::createFromGlobals();

    $placeRepo = $em->getRepository( "RowocoAllgemeinBundle:Place" );
    $placeEntity = $placeRepo->findBy(
        array(),
        array(),
        $request->request->get( "limitCount" ),
        $request->request->get( "limitStart" )
    );
    //return $placeEntity;

    $q = $em
        ->createQuery("SELECT p.description
                           FROM RowocoAllgemeinBundle:Place p
                           ");
    return $q->getResult();

}

I have no special repository or else. But when i use findby(), then i dont get a result. When use createQuery, I got 2 rows as result.

Can you tell me, where i can find the error in my code?

Upvotes: 0

Views: 104

Answers (1)

lxg
lxg

Reputation: 13107

findBy expects an array of key/values, like this one:

array(
    'id' => 5,
    'name' => 'john',
    'friends' => array(1,23)
);

As you can see in the last entry, you can also pass an array, which has the effed of a WHERE … IN() query. What you cannot (AFAIK) pass to findBy are ranges and complex patterns.

Upvotes: 0

Related Questions