dplht39359 2011-07-14 09:48
浏览 20
已采纳

如何在Doctrine 2 DQL查询中正确指定模型/表名?

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.

  • 写回答

1条回答 默认 最新

  • dongxi1320 2011-07-14 10:14
    关注

    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?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab