Symfony2 and Doctrine - Error: Invalid PathExpression. Must be a StateFieldPathExpression

后端 未结 3 1363
忘了有多久
忘了有多久 2020-11-27 16:33

I have an entity that looks like this:

/**
 * @Gedmo\\Tree(type=\"nested\")
 * @ORM\\Table(name=\"categories\")
 * @ORM\\Entity()
 */
class Category extends          


        
相关标签:
3条回答
  • 2020-11-27 16:50

    Solution using createQueryBuilder:

    $query->SELECT('pa.id')
            ->from('Category', 'ca');
    $query->join('ca.parent', 'pa');
    
    $result = $query->getQuery()->getArrayResult();
    
    0 讨论(0)
  • 2020-11-27 16:59

    You can use the currently undocumented IDENTITY function to select the FK IDs in a query:

    SELECT IDENTITY(c.parent) ...
    
    0 讨论(0)
  • 2020-11-27 16:59

    You are selecting an object that is not joined. Like said in another answer, you have to do something like :

    qb->innerJoin("c.parent", "p")
    
    0 讨论(0)
提交回复
热议问题