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