How to get Doctrine entity persistent collection data values with symfony
Asked Answered
O

3

8

What is best way to convert Doctrine entity persistent collection to array with symfony 2 ? I want to get the values and later by using that array value, need to get the second entity values which dependent on first entity using form event listener.

Orpah answered 12/3, 2019 at 12:27 Comment(0)
I
19

If I understand your question correctly, this helps you:

$arrayValues = $persistentCollection->getValues();

Incinerate answered 12/3, 2019 at 12:34 Comment(0)
T
4
$yourCollection->unwrap()->toArray();

That should give you the content of your collection as an array()

Tude answered 12/3, 2019 at 12:34 Comment(0)
N
0

For me, I have a relationship between two entities, so I retrieve the values from the related table like this $menu->getGallery()->toArray()

Nasya answered 2/10, 2023 at 7:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.