2014-10-03 138 views
10

我試圖在現有數據庫上添加Doctrine。我讓Doctrine生成帶註釋的實體並從那裏進行調整。當我嘗試下面我得到的錯誤加載實體PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Property Users\\User::$resellerID does not exist'Doctrine ReflectionException屬性不存在

class User 
{ 
    /* ... */ 

    /** 
    * @var \Doctrine\Common\Collections\Collection 
    * 
    * @ORM\ManyToOne(targetEntity="\Resellers\Reseller") 
    * @ORM\JoinTable(name="reseller", 
    * joinColumns={ 
    *  @ORM\JoinColumn(name="resellerID", referencedColumnName="resellerID") 
    * }, 
    * inverseJoinColumns={ 
    *  @ORM\JoinColumn(name="resellerID", referencedColumnName="resellerID") 
    * } 
    *) 
    */ 
    private $reseller; 

    /* ... */ 
} 

無論是userreseller表有resellerID列。我的理解是,對於加入ID列,您不要將ID列添加爲實體類中的屬性。那麼是什麼導致ReflectionException?

回答

30

由於我已將自動生成的屬性從resellerID重命名爲reseller(嘗試使用它之後),事實證明我需要清除Doctrine緩存。

php vendor/bin/doctrine.php orm:clear-cache:result 
php vendor/bin/doctrine.php orm:clear-cache:query 
php vendor/bin/doctrine.php orm:clear-cache:metadata 

或者,如果你正在使用的Symfony與學說:

php bin/console doctrine:cache:clear-result 
php bin/console doctrine:cache:clear-query 
php bin/console doctrine:cache:clear-metadata 
+0

清除緩存爲每一次我有一個我做的第一件事在Symfony中出現錯誤... – user276648 2016-03-21 03:36:31

2

對我來說clearing the PHP APC cache是解決

<?php 
apc_clear_cache(); 
+0

這就是我最終需要的 - 清理教條緩存原來是一種臨時措施,只有當我重新啓動memcached時,我才擺脫了錯誤。 – beterthanlife 2017-07-13 09:22:18

相關問題