1

I am trying to create a query with the doctrine query builder:

public function searchAuthors($q)
{
    $qb = $this->createQueryBuilder('Author')
    ->field('person.firstname')->equals('test');

    return $qb->getQuery()->getResult();
}

But I am getting :

Fatal error: Call to undefined method Doctrine\ORM\QueryBuilder::field() in ... on line 18 

The field() method is from the doctrine documentation webpage. Could you please help me to resolve that.

Thank you.

Milos Cuculovic
  • 19,631
  • 51
  • 159
  • 265
  • Same as [here](http://stackoverflow.com/questions/14560575/orm-querybuilder-with-entity-subobjects), you need to use left join. – Mick Jan 28 '13 at 11:38
  • Thank you Patt, but my question was more about why the field() method is undefined... – Milos Cuculovic Jan 28 '13 at 11:43

1 Answers1

6

field() exists only in Doctrine MongoDB ODM (to use it see here) not in Doctrine 2 ORM.

Mick
  • 30,759
  • 16
  • 111
  • 130