0

当我尝试执行此 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

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

// 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;

知道为什么会这样吗?

4

1 回答 1

6

您的文档块中有错字$rules:您忘记了@OneToMany 之前的标志

文档块应该是:

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

代替

/**
 * OneToMany(targetEntity="Rule", mappedBy="splash_page") 
 */
protected $rules = null;
于 2012-07-07T19:45:42.877 回答