Doctrine2:未定义的索引

时间:2012-07-07 15:52:32

标签: php doctrine doctrine-orm

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

SELECT r, s FROM Rule r
JOIN r.splash_page s
WHERE r.active = 1

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

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

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

// Rule.php 
/**
 *
 * @var type 
 * @ManyToOne(targetEntity="SplashPage", inversedBy="rules")
 */
protected $splash_page;

// SplashPage.php
/**
 *
 * @var type
 * OneToMany(targetEntity="Rule", mappedBy="splash_page") 
 */
protected $rules = null;

知道为什么会这样吗?

1 个答案:

答案 0 :(得分:6)

您的$rules文件夹中有拼写错误:您在OneToMany之前忘记了@标志

docblock应该是:

/**
 * @OneToMany(targetEntity="Rule", mappedBy="splash_page") 
 */
protected $rules = null;

而不是

/**
 * OneToMany(targetEntity="Rule", mappedBy="splash_page") 
 */
protected $rules = null;
相关问题