Doctrine ReflectionException属性不存在
问题描述:
我试图在现有数据库上添加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;
/* ... */
}
无论是user
和reseller
表有resellerID
列。我的理解是,对于加入ID列,您不要将ID列添加为实体类中的属性。那么是什么导致ReflectionException?
答
由于我已将自动生成的属性从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
答
对我来说clearing the PHP APC cache是解决
<?php
apc_clear_cache();
+0
这就是我最终需要的 - 清理教条缓存原来是一种临时措施,只有当我重新启动memcached时,我才摆脱了错误。 – beterthanlife 2017-07-13 09:22:18
清除缓存为每一次我有一个我做的第一件事在Symfony中出现错误... – user276648 2016-03-21 03:36:31