本文介绍了检查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是否为空
发布评论