检查ArrayCollection是否为空 [英] Check if ArrayCollection is empty
本文介绍了检查ArrayCollection是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个实体订单,该订单将供应商保存在Arraycollection中. 在我的控制器中,我要检查此arraycollection是否为空:
I have an Entity Order which hold Suppliers in an Arraycollection. In my controller i want to check if this arraycollection is empty:
$suppliers = $order->getSuppliers();
我尝试过:
if(!($suppliers)) {}
if(empty($suppliers)) {}
有什么想法吗?
推荐答案
Doctrine ArrayCollection具有方法isEmpty
,它将完成您要查找的内容.
Doctrine ArrayCollection has a method isEmpty
that will do what you are looking for.
if ($suppliers->isEmpty()) { }
看看它的文档这里
这篇关于检查ArrayCollection是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文