【发布时间】:2013-01-26 17:23:06
【问题描述】:
我有以下代码:
$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”中的属性“_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
有人知道为什么吗?
谢谢
【问题讨论】:
标签: php doctrine doctrine-orm arraycollection