1
エンティティ内のいくつのフィールドがヌルでないかをカウントしようとしています。具体的には、プロパティがArrayCollectionの場合、コレクションが空でないかどうかを識別します。ここでエンティティのプロパティを反復し、ヌル値でない値を返します。
どのエンティティプロパティをループすると、空のヌルかどうかではない性質を数える私は、すべてのユーザーオブジェクトのプロパティに
$properties = $em->getClassMetadata('AppBundle:User')->getFieldNames();
$output = array_merge(
$properties,
$em->getClassMetadata('AppBundle:User')->getAssociationNames()
);
foreach($output as $property){
????
}
質問を取得しています。
var_dump($output)
出力:
array (size=47)
0 => string 'username' (length=8)
1 => string 'usernameCanonical' (length=17)
2 => string 'email' (length=5)
3 => string 'emailCanonical' (length=14)
...
45 => string 'expertise' (length=13) // ManyToOne association
46 => string 'reports' (length=7) // OneToMany association. type ArrayCollection