PachinSV
PachinSV

Reputation: 3780

Doctrine2: undefined index

When I try to execute this DQL query:

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

What I'm trying to do is just join two Entities and I get this error:

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

These are part of my Entity files where I declare the relation between them:

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

Any idea why is this happening?

Upvotes: 0

Views: 3578

Answers (1)

AdrienBrault
AdrienBrault

Reputation: 7745

You have a typo in your $rules docblock: you have forgotten the @ sign before OneToMany

The docblock should be:

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

instead of

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

Upvotes: 5

Related Questions