Search code examples
phpzend-frameworknamespacesdoctrine-ormdql

How do I correctly specify model/table name in Doctrine 2 DQL query?


I've upgraded to Doctrine 2 in my Zend application. I have the following code in a controller:

// get instance of entity manager
$em = $this->_helper->Em();

// get instance of query builder
$qb = $em->createQueryBuilder();

$qb->select('g')
->from('Groups', 'g');

$query = $qb->getQuery();   
$aGroups = $query->getResult();

However it throws the error: Message:[Semantical Error] line 0, col 14 near 'Groups g': Error: Class 'Groups' is not defined.

The entities are in application/models/Entities/

Appreciate the help.


Solution

  • Two ideas:

    1. Is Group the complete classname? The DQL queries with which I am familiar use the complete class name. Is there some pseudo-namespace on the class, like Application_Model_Group, Application_Entity_Group, or some such thing?

    2. Is the classname singular Group rather than plural Groups?