我正在將網站重構爲Zend Framework 1.11/Doctrine 2,並且有許多包含具有下劃線的列名的遺留表(例如plant_id)。 (最初是相當透徹的,但是我對教義印象深刻!)使用含有下劃線的列的Doctrine2/Zend Framework 1.11
我已經成功地建立了一個學說實體(遵循WJ Gilmores的優秀着作Easy PHP和Zend Framework),但在使用Doctrine's findOne神奇取景器與包括傳統的列名強調
代碼
$plant = $this->em->getRepository('Entities\Plant')
->findOneByPlant_id('3571');
返回一個錯誤
Message: Entity 'Entities\Plant' has no field 'plantId'. You can therefore not call 'findOneByPlant_id' on the entities' repository
(順便說一句,Doctrine否則看起來很好 - 我們創建了一個實體,並將其作爲我們的列名稱,並且可以檢索此列。)
我們通過使用查詢構建器構建查詢來解決此問題。
是否還有其他更簡單的解決方案,除了更改整個整個表格以刪除下劃線(不容易,因爲有大量遺留代碼,我們將不得不返回),不需要太多的代碼?
Brill。很有幫助。 – C4PO 2012-03-06 11:44:09