我想检查存储库中是否有数据:
$dataCollection = $this->em->getRepository(Data::class)->DataConnector($fieldId,$id);
if(isset($dataCollection)){
echo "this contains data";
} else {
echo "this does not contain data";
}
但是即使存储库中没有数据,我也总是收到消息“其中包含数据”。
答案 0 :(得分:0)
输出([]
)是一个空数组。设置了一个空数组:
$x = [];
print_r(isset($x)); // 1
print_r(empty($x)); // 1
print_r(count($x)); // 0
答案 1 :(得分:-2)
$dataCollection = $this->em->getRepository(Data::class)->DataConnector($fieldId,$id);
if(dataCollection != NULL){
echo "this contains data";
} else {
echo "this does not contain data";
}