Doctrine ReflectionException属性不存在 [英] Doctrine ReflectionException property does not exist
问题描述
我正在尝试在现有数据库之上添加Doctrine。我让Doctrine生成注释实体并从那里进行调整。当我尝试加载下面的实体时,我得到错误 PHP致命错误:未捕获异常ReflectionException与消息'Property Users\\User :: $ resellerID不存在'
I'm trying to add Doctrine on top of an existing database. I let Doctrine generate annotated entities and adjusted from there. When I try to load the entity below I get the error PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Property Users\\User::$resellerID does not exist'
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;
/* ... */
}
用户
和经销商
表具有 resellerID
列。我的理解是,对于加入ID列,不要在实体类中添加ID列作为属性。那么导致ReflectionException的原因是什么?
Both the user
and reseller
tables have resellerID
columns. My understanding is that for joining ID columns you don't add the ID columns as properties in the entity class. So what's causing the ReflectionException?
推荐答案
自从我将自动生成的属性从 resellerID
到经销商
(尝试使用它后)原来我需要清除Doctrine缓存。
Since I had renamed the autogenerated property from resellerID
to reseller
(after trying to use it) it turns out I needed to clear the Doctrine cache.
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
这篇关于Doctrine ReflectionException属性不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!