2

我在使用学说通过 DQL 做一个简单的请求时遇到了一些麻烦。在我的代码中找不到任何错误,所以我在这里问我的问题。

这是我尝试执行的 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”已正确创建和填充。我尝试了一些修复但没有成功:

  • 停用缓存
  • 尝试重命名字段

我该如何解决?

4

1 回答 1

3

元数据@Colum应该是@Column

于 2013-04-30T12:50:28.143 回答