$prueba = array (
=> obj(),
=> obj(),
...
)
Rellenado con un foreach, y pasandole objetos con doctrine de symfony2, esto no es relevante, solo lo comento, porque si uso el findOneByname, me da un objeto y no un array; y se que esuna solucion posible, pero me gustaria saber como resolverlo como array:
Código:
Al hacer var_dump me queda esto:$prueba = $em->getRepository('MistakesTestBundle:Error')->findByName($error['name']);
Cita:
array(1) { [0]=> object(Mistakes\MistakesTestBundle\Entity\Error)#2 89 (4) { ["id":"Mistakes\MistakesTestBundle\Entity\Error":pr ivate]=> int(235) ["ab_id":"Mistakes\MistakesTestBundle\Entity\Error" :private]=> int(64434) ["name":"Mistakes\MistakesTestBundle\Entity\Error": private]=> string(10) "Bancontact" ["cont":"Mistakes\MistakesTestBundle\Entity\Error": private]=> int(213) } } array(1) { [0]=> object(Mistakes\MistakesTestBundle\Entity\Error)#2 91 (4) { ["id":"Mistakes\MistakesTestBundle\Entity\Error":pr ivate]=> int(236) ["ab_id":"Mistakes\MistakesTestBundle\Entity\Error" :private]=> int(65378) ["name":"Mistakes\MistakesTestBundle\Entity\Error": private]=> string(19) "ClubBrugge-facebook" ["cont":"Mistakes\MistakesTestBundle\Entity\Error": private]=> int(0) } } array(1) { [0]=> object(Mistakes\MistakesTestBundle\Entity\Error)#2 87 (4) { ["id":"Mistakes\MistakesTestBundle\Entity\Error":pr ivate]=> int(237) ["ab_id":"Mistakes\MistakesTestBundle\Entity\Error" :private]=> int(64514) ["name":"Mistakes\MistakesTestBundle\Entity\Error": private]=> string(5) "FACTV" ["cont":"Mistakes\MistakesTestBundle\Entity\Error": private]=> int(2) } } array(1) { [0]=> object(Mistakes\MistakesTestBundle\Entity\Error)#2 83 (4) { ["id":"Mistakes\MistakesTestBundle\Entity\Error":pr ivate]=> int(238) ["ab_id":"Mistakes\MistakesTestBundle\Entity\Error" :private]=> int(52497) ["name":"Mistakes\MistakesTestBundle\Entity\Error": private]=> string(17) "Kunstmaan Sandbox" ["cont":"Mistakes\MistakesTestBundle\Entity\Error": private]=> int(18) } } array(1) { [0]=> object(Mistakes\MistakesTestBundle\Entity\Error)#2 85 (4) { ["id":"Mistakes\MistakesTestBundle\Entity\Error":pr ivate]=> int(239) ["ab_id":"Mistakes\MistakesTestBundle\Entity\Error" :private]=> int(71158) ["name":"Mistakes\MistakesTestBundle\Entity\Error": private]=> string(15) "KustZe Facebook" ["cont":"Mistakes\MistakesTestBundle\Entity\Error": private]=> int(0) } } array(1) { [0]=> object(Mistakes\MistakesTestBundle\Entity\Error)#2 81 (4) { ["id":"Mistakes\MistakesTestBundle\Entity\Error":pr ivate]=> int(240) ["ab_id":"Mistakes\MistakesTestBundle\Entity\Error" :private]=> int(77742) ["name":"Mistakes\MistakesTestBundle\Entity\Error": private]=> string(5) "POPiK" ["cont":"Mistakes\MistakesTestBundle\Entity\Error": private]=> int(0) } } array(1) { [0]=> object(Mistakes\MistakesTestBundle\Entity\Error)#2 77 (4) { ["id":"Mistakes\MistakesTestBundle\Entity\Error":pr ivate]=> int(241) ["ab_id":"Mistakes\MistakesTestBundle\Entity\Error" :private]=> int(72930) ["name":"Mistakes\MistakesTestBundle\Entity\Error": private]=> string(12) "Telenet GWOF" ["cont":"Mistakes\MistakesTestBundle\Entity\Error": private]=> int(0) } } array(1) { [0]=> object(Mistakes\Mi... etc
Mi pregunta es, cómo podría acceder al [cont] del objeto error, si tengo perfectamente configurado mis Getters and Setters?
$prueba->setCont('X'])
Así no funciona porque $prueba es un array, no es un objeto en si, como accedo pues a ese vqlor, es mi pregunta, es puramente un error de concepto que no he entendido al tratar arrays de objetos.
Muchas gracias.