excluded excluded - 2 months ago 7
PHP Question

I receive Persitent Collection instead of ArrayCollection

I want to see if my record in database has related photos or not. But when I call

, I get the instance of
, and
show the same result for car what has photos, and for car what has no car_photos. Where is my problem? Please , help me.


So what is bothering you? It is supposed to return you collection in both cases. To check whether car has related photos:

if ($car->getCarPhotos()->isEmpty()) {
    // Car has no photos
} else {
    // Car has photos