我有以下代码:
$countries = $em->getRepository("country")->findAll();
$array = array();
$count = 0;
foreach($countries as $country){
if(is_object($country)){
if($country->getCompaniesCount() > 0)
$array[$count] = $country;
$count++;
}
}
调用的“getCompaniesCount”函数如下所示:
public function getCompaniesCount(){
return $this->_comapanies->count();
}
但它会产生一个我无法理解的错误。
“country”中有国家,有与国家相关的“公司”。所以国家和公司是多对多关系。并且“country”中的属性“_companies”被初始化为 ArrayCollection 来保存公司。
但是每次我运行此代码时,都会出现以下错误:
Catchable fatal error:
Argument 1 passed to Doctrine\ORM\Mapping\DefaultQuoteStrategy::getJoinTableName() must be an array, null given,
called in /usr/share/pear/Doctrine/ORM/Persisters/BasicEntityPersister.php on line 965
and defined in /usr/share/pear/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php on line 86
有谁知道为什么?
谢谢