php - When I retrieve my ArrayCollection the keys are missing -


i'm working on symfony2, using doctrine2. problem when save array collection keys, moment retrieve them, keys usual 0 n array index keys, not ones put in.

this entity:

 /**  * @var array  * @orm\onetomany(targetentity="subentity", mappedby="identity", cascade={"persist"}, indexby="idsubentity")  */ protected $arraysubentities;  /** * @param array() $subentitiesarray     simple array "subentity" objects * */ public function __construct($subentitiesarray) {     $this->arraysubentities = new arraycollection;      foreach ($subentitiesarray $subentity){         $subentity->setidentity($this);         $this->addarraysubentities($subentity->getidsubentitytype()->getid(), $subentity);     }   public function addarraysubentities($key, \project\entity\subentitybd $subentity) {     $this->arraysubentities->set($key, $subentity);      return $this; }  public function getarraysubentities() {     return $this->arraysubentities; } 

this "save" part:

$subentitytypes = $this->em->getrepository('projectbundle:subentitytype')->findall();  $subentitiesarray = array(); foreach ($subentitytypes $subentitytype) {     $subentitiesarray[] = new subentity($subentitytype); }  $entity = new entity($subentitiesarray); var_dump($entity); 

the 'var_dump()' @ end shows entity correct keys, correct classes, right.

the problem:

$entity = $this->em->getrepository('projectbundle:entity')->find($identity);  $subentitiesarray = $entity->getarraysubentities(); var_dump($subentitiesarray); 

this last 'var_dump()' shows same array, 0 n keys.

by way, want entity have array collection subentities related to, , indexed type of subentity are. said, works fine on first step, when retrieve arraycollection entity has lost it's keys. did 'var_dump()' entity self after retrieving , array keys 0 n too.

thanks in advance, cheers.

solved: looks retrieve new formed array, thats why keys had lost.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -