2
我在使用原则做DQL的简单请求时遇到了一些麻烦。 在我的代码中找不到任何错误,所以我在这里问我的问题。原则2:实体没有字段或关联名为x
这里是dcotrine查询我试图执行:
$em->createQueryBuilder()->select('p')
->from('\lib\models\HarvestPage', 'p')
->where('(p.start_hp + ?1 <= p.end_hp OR p.end_hp = 0) AND p.label_hp NOT IN (SELECT r.label_hp FROM \lib\models\HarvestRequest r)')
->setMaxResults(1)
->setParameter(1, $nbPages)
->getQuery()
->useResultCache(false)
->getOneOrNullResult();
它将引发我此异常:
[Semantical Error] line 0, col 49 near 'start_hp + ?1': Error: Class lib\models\HarvestPage has no field or association named start_hp
而在去年,该HarvestPage实体:
namespace lib\models;
/**
* @Entity
* @Table(name="harvest_page")
*/
class HarvestPage {
/** @Id @Column(type="string", length=25) */
private $label_hp;
/** @Column(type="string", length=200, nullable=false) */
private $link_hp;
/** @Colum(type="smallint", nullable=false) */
private $start_hp;
/** @Colum(type="smallint", nullable=false) */
private $end_hp;
}
表“harvest_page”被正确创建和填充。 我已经尝试了一些修正,但没有成功:
- Desactivate缓存
- 尝试重命名场
我该如何解决呢?
OMG感谢,我的错误是太明显了,我没有找到它... – 2013-04-30 13:04:40
没问题,很高兴我能帮助 – AlexP 2013-04-30 14:20:26