Whenever I use ArrayCollection with ORM (Doingrine ORM) (2.3, PHP> 5.4) and match the values โโof the object with the key in the collection (for example, using the set method), the values โโare stored correctly in the database, but when I want to extract the collection from the essence, keys are not obtained, and instead they use a numerical index.
For example, if I have the following classes:
class MyEntity { private $myArray; public function __construct() { $this->myArray = new ArrayCollection(); } public function addOtherEntity($key, $value) { $this->myArray->set($key, $value); } ... } class MyOtherEntity { private $mainEntity; ... }
The set method works correctly, but when I retrieve the information, the keys in $myArray gone.
How to make ORM remember keys correctly? Thanks in advance.
Carlos Vergara
source share