excluded excluded - 1 year ago 64
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download