Doctrine2:未定义的索引

Pac*_*nSV 0 php doctrine doctrine-orm

当我尝试执行此DQL查询时:

SELECT r, s FROM Rule r
JOIN r.splash_page s
WHERE r.active = 1
Run Code Online (Sandbox Code Playgroud)

我想要做的只是加入两个实体,我得到这个错误:

Notice: Undefined index: rules in C:\xampp\htdocs\excap\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 110
Notice: Undefined index: rules in C:\xampp\htdocs\excap\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 428
Notice: Undefined index: rules in C:\xampp\htdocs\excap\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 428
Notice: Undefined index: rules in C:\xampp\htdocs\excap\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 428
Notice: Undefined index: rules in C:\xampp\htdocs\excap\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 428
Run Code Online (Sandbox Code Playgroud)

这些是我的Entity文件的一部分,我在其中声明它们之间的关系:

// Rule.php 
/**
 *
 * @var type 
 * @ManyToOne(targetEntity="SplashPage", inversedBy="rules")
 */
protected $splash_page;
Run Code Online (Sandbox Code Playgroud)
// SplashPage.php
/**
 *
 * @var type
 * OneToMany(targetEntity="Rule", mappedBy="splash_page") 
 */
protected $rules = null;
Run Code Online (Sandbox Code Playgroud)

知道为什么会这样吗?

Adr*_*ult 6

你的$rulesdocblock中有一个拼写错误:你@在OneToMany之前忘记了这个标志

docblock应该是:

/**
 * @OneToMany(targetEntity="Rule", mappedBy="splash_page") 
 */
protected $rules = null;
Run Code Online (Sandbox Code Playgroud)

代替

/**
 * OneToMany(targetEntity="Rule", mappedBy="splash_page") 
 */
protected $rules = null;
Run Code Online (Sandbox Code Playgroud)