I have Zend Framework 3 + Doctrine ORM application.
Class Goods have link "characters":
/**
* Goods
*
* @ORM\Entity
* @ORM\Table(name="goods")
* @property int $id
*/
class Goods implements InputFilterAwareInterface
{
/**
* @ORM\ManyToMany(targetEntity="\Application\Entity\CharacterValue", inversedBy="goods")
* @ORM\JoinTable(name="character_value_item",
* joinColumns={@ORM\JoinColumn(name="good_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="value_id", referencedColumnName="id")})
**/
protected $characters;
public function getCharacters()
{
return $this->characters;
}
}
I trying to use this method to get characters by method for lazy loading, but it returns just one character. Not all characters for the product.
$dql = 'SELECT u, ch FROM Goods u LEFT JOIN u.characters ch';
This method from here:
$query = $em->createQuery('SELECT u, p FROM CmsUser u JOIN u.phonenumbers p');
$users = $query->getResult(); // array of CmsUser objects with the phonenumbers association loaded
$phonenumbers = $users[0]->getPhonenumbers();
I do not understand why documentation's method working wrong. What is the right way to deside my issue?